Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Passing literal string to function

fn main() {
    let name = "Foo Bar";
    greet(name);
    greet(name);
}

fn greet(text: &str) {
    println!("Greet: {text}");
}
Greet: Foo Bar
Greet: Foo Bar