Passing literal string to function
examples/ownership/str/src/main.rs
fn main() { let name = "Foo Bar"; greet(name); greet(name); } fn greet(text: &str) { println!("Greet: {text}"); }
Greet: Foo Bar Greet: Foo Bar
fn main() { let name = "Foo Bar"; greet(name); greet(name); } fn greet(text: &str) { println!("Greet: {text}"); }
Greet: Foo Bar Greet: Foo Bar