]> git.scottworley.com Git - tablify/commitdiff
Refactor: Collect to Vec and join(" ")
authorScott Worley <scottworley@scottworley.com>
Sat, 24 Aug 2024 09:32:59 +0000 (02:32 -0700)
committerScott Worley <scottworley@scottworley.com>
Wed, 2 Oct 2024 09:40:47 +0000 (02:40 -0700)
src/lib.rs

index c261c782e8a0e69e478f61d04fe162687bf21c7b..e636bb23a1596b3cdecfaad5228ff3323f6de5a1 100644 (file)
@@ -150,8 +150,8 @@ fn column_order(rows: &[RowInput]) -> Vec<String> {
 
 fn render_instance(entry: &Entry) -> String {
     match &entry.instance {
-        None => String::from("✓ "),
-        Some(instance) => String::from(instance) + " ",
+        None => String::from("✓"),
+        Some(instance) => String::from(instance),
     }
 }
 
@@ -169,9 +169,10 @@ fn render_cell(col: &str, row: &RowInput) -> String {
         entries
             .iter()
             .map(|i| render_instance(i))
-            .collect::<String>()
+            .collect::<Vec<_>>()
+            .join(" ")
     };
-    format!("<td class=\"{class}\" onmouseover=\"h2('{row_label}','{col}')\" onmouseout=\"ch2('{row_label}','{col}')\">{}</td>", contents.trim())
+    format!("<td class=\"{class}\" onmouseover=\"h2('{row_label}','{col}')\" onmouseout=\"ch2('{row_label}','{col}')\">{contents}</td>")
 }
 
 fn render_row(columns: &[String], row: &RowInput) -> String {