std-method
String::push_str
Append a borrowed text fragment, leaving its owner usable. The destination may need more allocation. Expected stdout (not executed): Task done " done" Common mistake: Moving the suffix unnecessarily or passing a char instead of &str.
Formal Syntax & Structure
rust syntaxrust
fn push_str(&mut self, string: &str)Working Example
Example Snippetrust
fn main() { let suffix = String::from(" done"); let mut status = String::from("Task"); status.push_str(&suffix); println!("{status}"); println!("{suffix:?}");}