]> git.scottworley.com Git - tablify/blobdiff - src/lib.rs
Refactor: Collect to Vec and join(" ")
[tablify] / src / lib.rs
index fbafcb1726863ebac3aba8407b174820a1038c56..e636bb23a1596b3cdecfaad5228ff3323f6de5a1 100644 (file)
@@ -9,6 +9,7 @@ const HEADER: &str = "<!DOCTYPE html>
   <meta charset=\"utf-8\">
   <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
   <style>
   <meta charset=\"utf-8\">
   <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
   <style>
+    td { text-align: center; }
     /* h/t https://wabain.github.io/2019/10/13/css-rotated-table-header.html */
     th, td { white-space: nowrap; }
     th { text-align: left; font-weight: normal; }
     /* h/t https://wabain.github.io/2019/10/13/css-rotated-table-header.html */
     th, td { white-space: nowrap; }
     th { text-align: left; font-weight: normal; }
@@ -149,8 +150,8 @@ fn column_order(rows: &[RowInput]) -> Vec<String> {
 
 fn render_instance(entry: &Entry) -> String {
     match &entry.instance {
 
 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),
     }
 }
 
     }
 }
 
@@ -168,9 +169,10 @@ fn render_cell(col: &str, row: &RowInput) -> String {
         entries
             .iter()
             .map(|i| render_instance(i))
         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 {
 }
 
 fn render_row(columns: &[String], row: &RowInput) -> String {