]> git.scottworley.com Git - tablify/commitdiff
Clippy wants this to use mut and write!
authorScott Worley <scottworley@scottworley.com>
Mon, 19 Aug 2024 20:56:55 +0000 (13:56 -0700)
committerScott Worley <scottworley@scottworley.com>
Mon, 19 Aug 2024 20:56:55 +0000 (13:56 -0700)
src/lib.rs

index 5de1c121059ebbc4168a0b952d303fa195f1c4a1..a3878c56f879436aedd0d18220a60a076e3ffa7c 100644 (file)
@@ -1,4 +1,5 @@
 use std::collections::{HashMap, HashSet};
 use std::collections::{HashMap, HashSet};
+use std::fmt::Write;
 use std::io::BufRead;
 use std::iter::Iterator;
 
 use std::io::BufRead;
 use std::iter::Iterator;
 
@@ -190,10 +191,10 @@ fn render_row(columns: &[String], row: &RowInput) -> String {
 fn render_column_headers(columns: &[String]) -> String {
     // TODO: Escape HTML special characters
     String::from("<th></th>")
 fn render_column_headers(columns: &[String]) -> String {
     // TODO: Escape HTML special characters
     String::from("<th></th>")
-        + &columns
-            .iter()
-            .map(|c| format!("<th>{c}</th>"))
-            .collect::<String>()
+        + &columns.iter().fold(String::new(), |mut acc, c| {
+            write!(&mut acc, "<th>{c}</th>").unwrap();
+            acc
+        })
         + "\n"
 }
 
         + "\n"
 }