std-type

String — owned growable UTF-8 text

A String owns its UTF-8 contents and can grow or shrink. Borrow it as &str when a function only needs to read it. Expected stdout (not executed): Order ready Common mistake: Expecting a string literal binding to support push_str.

Formal Syntax & Structure

rust syntaxrust
String::from(text)

Working Example

Example Snippetrust
fn main() {    let mut note = String::from("Order");    note.push_str(" ready");    println!("{note}");}
Rust Reference