diff --git a/allocative/allocative/src/golden.rs b/allocative/allocative/src/golden.rs index bee5ab960..6afcde98e 100644 --- a/allocative/allocative/src/golden.rs +++ b/allocative/allocative/src/golden.rs @@ -10,6 +10,7 @@ #![cfg(test)] use std::env; +use std::fmt::Write; use std::fs; use crate::Allocative; @@ -50,8 +51,10 @@ fn make_golden(value: &T) -> (String, String) { "{header}{flamegraph}", header = golden_header() .lines() - .map(|line| format!("# {}\n", line)) - .collect::() + .fold(String::new(), |mut output, line| { + let _ = writeln!(output, "# {}", line); + output + }) ); let flamegraph_svg = flamegraph_svg.replace( diff --git a/starlark/src/docs/markdown.rs b/starlark/src/docs/markdown.rs index 31f60b150..aa38bcdcf 100644 --- a/starlark/src/docs/markdown.rs +++ b/starlark/src/docs/markdown.rs @@ -15,6 +15,7 @@ * limitations under the License. */ +use std::fmt::Write; use std::slice; use dupe::Dupe; @@ -143,11 +144,11 @@ fn render_function_parameters(params: &[DocParam]) -> Option { DocParam::Args { name, docs, .. } => Some((name, docs)), DocParam::Kwargs { name, docs, .. } => Some((name, docs)), }) - .map(|(name, docs)| { + .fold(String::new(), |mut output, (name, docs)| { let docs = render_doc_string(DSOpts::Combined, docs).unwrap_or_default(); - format!("* `{name}`: {docs}\n") - }) - .collect(); + let _ = writeln!(output, "* `{name}`: {docs}"); + output + }); Some(param_list) }