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

Integers are copies

  • Make the copy mutable
fn main() {
    let a = 23;
    println!("{a}");

    let mut b = a;
    println!("{b}");

    b = 42;
    println!("{a}");
    println!("{b}");
}
23
23
23
42