String
Examples
let s = String::new();
s.push_str("123");
Q&A
What's the defference between `write!` and `push_str`?
write!directly writes togreetings
use std::fmt::Write;
let mut greetings = String::from("Hello");
let x: u8 = 10;
write!(greetings, " No.{}", x).unwrap();
push_strwill allocate aString, get its ref and copy it togreetings, then throw it away
let mut greetings = String::from("Hello");
let x: u8 = 10;
greetings.push_str(&!format("{}", x));