I see now that String implements Write, so we can use write!:
use std::fmt::Write;
pub fn main() {
let mut a = "hello ".to_string();
write!(a, "{}", 5).unwrap();
println!("{}", a);
assert_eq!("hello 5", a);
}
(Playground)
It is impossible for this write! call to return an Err, at least as of Rust 1.47, so the unwrap should not cause concern.