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

Mutable integers are copies

  • Both are mutable
fn main() {
    let mut a = 23;
    println!("{a}");

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

    a += 1;
    println!("{a}");
    println!("{b}");

    b += 1;
    println!("{a}");
    println!("{b}");
}
23
23
24
23
24
24