std-method
String::new
Start with empty owned text when fragments will be added later. Expected stdout (not executed): true OK Common mistake: Expecting a new String to contain a null terminator as content.
Formal Syntax & Structure
rust syntaxrust
fn new() -> StringWorking Example
Example Snippetrust
fn main() { let mut report = String::new(); println!("{}", report.is_empty()); report.push_str("OK"); println!("{report}");}