Format! to string_builder

Suppose we are building a big string from lots of small components. One way is to format! each small component, get a Vec<String>, then concat it.

I am wondering if, instead, there is a way to do:

let mut string_builder = ....
format!(string_builder, ....)
format!(string_builder, ...)

i.e. instead of building this `Vec<String>` of fragments, we get `format!` to write directly into the string_builder.

Yeah, use write! instead.


String implements Write so you can use write!.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.