]> git.r.bdr.sh - rbdr/page/commitdiff
Use String::new() for empty strings
authorRuben Beltran del Rio <redacted>
Sat, 4 Jan 2025 01:25:11 +0000 (02:25 +0100)
committerRuben Beltran del Rio <redacted>
Sat, 4 Jan 2025 01:25:11 +0000 (02:25 +0100)
src/file_finder.rs
src/gemini_parser.rs
src/html_renderer.rs

index 0512146d3e5c93e53658761fab12f09fb64e189e..a834bd99e33f6f90d178453028a8a5bb9b30f3e8 100644 (file)
@@ -89,9 +89,9 @@ mod tests {
                 Some("gmi") => assert_eq!(file.file_type, FileType::Gemini),
                 Some("html") => {
                     if file.path.ends_with("_layout.html") {
-                        assert_eq!(file.file_type, FileType::Layout)
+                        assert_eq!(file.file_type, FileType::Layout);
                     } else {
-                        assert_eq!(file.file_type, FileType::File)
+                        assert_eq!(file.file_type, FileType::File);
                     }
                 }
                 _ => assert_eq!(file.file_type, FileType::File),
index 49d954a20cfa3c30ec5fb5476f7b60aafe6e0584..f7aa0cc70b640794b9664f6314beb12685f80608 100644 (file)
@@ -82,7 +82,7 @@ mod tests {
             parse_line("# Heading"),
             GeminiLine::Heading(1, " Heading".to_string())
         );
-        assert_eq!(parse_line("###"), GeminiLine::Heading(3, "".to_string()));
+        assert_eq!(parse_line("###"), GeminiLine::Heading(3, String::new()));
         assert_eq!(
             parse_line("#####"),
             GeminiLine::Heading(3, "##".to_string())
@@ -111,16 +111,16 @@ mod tests {
         );
         assert_eq!(
             parse_line("=> /local/path"),
-            GeminiLine::Link("/local/path".to_string(), "".to_string())
+            GeminiLine::Link("/local/path".to_string(), String::new())
         );
 
         assert_eq!(
             parse_line("=>"),
-            GeminiLine::Link("".to_string(), "".to_string())
+            GeminiLine::Link(String::new(), String::new())
         );
         assert_eq!(
             parse_line("=> "),
-            GeminiLine::Link("".to_string(), "".to_string())
+            GeminiLine::Link(String::new(), String::new())
         );
         assert_eq!(
             parse_line("=>  multiple    spaces  in   text"),
@@ -140,7 +140,7 @@ mod tests {
             GeminiLine::ListItem("List item".to_string())
         );
 
-        assert_eq!(parse_line("* "), GeminiLine::ListItem("".to_string()));
+        assert_eq!(parse_line("* "), GeminiLine::ListItem(String::new()));
         assert_eq!(parse_line("*"), GeminiLine::Text("*".to_string(), false));
         assert_eq!(
             parse_line("*WithText"),
@@ -159,7 +159,7 @@ mod tests {
             GeminiLine::Quote("Quote text".to_string())
         );
 
-        assert_eq!(parse_line(">"), GeminiLine::Quote("".to_string()));
+        assert_eq!(parse_line(">"), GeminiLine::Quote(String::new()));
         assert_eq!(parse_line("> "), GeminiLine::Quote(" ".to_string()));
         assert_eq!(
             parse_line(">>Nested"),
@@ -176,7 +176,7 @@ mod tests {
 
         assert_eq!(
             parse_line("```"),
-            GeminiLine::PreformattedToggle(true, "".to_string())
+            GeminiLine::PreformattedToggle(true, String::new())
         );
         assert_eq!(
             parse_line("``` "),
@@ -189,11 +189,11 @@ mod tests {
 
         assert_eq!(
             parse_preformatted_line("```alt-text"),
-            GeminiLine::PreformattedToggle(false, "".to_string())
+            GeminiLine::PreformattedToggle(false, String::new())
         );
         assert_eq!(
             parse_preformatted_line("```"),
-            GeminiLine::PreformattedToggle(false, "".to_string())
+            GeminiLine::PreformattedToggle(false, String::new())
         );
     }
 
@@ -206,7 +206,7 @@ mod tests {
         );
 
         // Edge cases
-        assert_eq!(parse_line(""), GeminiLine::Text("".to_string(), false));
+        assert_eq!(parse_line(""), GeminiLine::Text(String::new(), false));
         assert_eq!(parse_line(" "), GeminiLine::Text(" ".to_string(), false));
         assert_eq!(parse_line("  "), GeminiLine::Text("  ".to_string(), false));
     }
@@ -265,7 +265,7 @@ code
                 GeminiLine::Text("=> https://example.com Link text".to_string(), true),
                 GeminiLine::Text("* List item".to_string(), true),
                 GeminiLine::Text(">Quote".to_string(), true),
-                GeminiLine::PreformattedToggle(false, "".to_string()),
+                GeminiLine::PreformattedToggle(false, String::new()),
             ]
         );
     }
index 77241317ac4ab18dbb4e21b77b90e2e151a42d25..6b9ce38471dbc41718f62c2799e917ced482c18a 100644 (file)
@@ -206,7 +206,7 @@ mod tests {
     fn test_links() {
         let input = vec![
             GeminiLine::Link("https://example.com".to_string(), "Example".to_string()),
-            GeminiLine::Link("https://rust-lang.org".to_string(), "".to_string()),
+            GeminiLine::Link("https://rust-lang.org".to_string(), String::new()),
         ];
         assert_eq!(
             render_html(&input),