Rust Ownership

A String owns its heap allocation. Passing &name borrows it for the function call, so the caller can still use name afterward.

Rust
fn show(value: &str) {
    println!("{}", value);
}
fn main() {
    let name = String::from("Ada");
    show(&name);
    println!("{}", name);
}
Read the full lesson