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

Pass integer to function return changed value

fn increment(x: i32) -> i32 {
    x + 1
}

fn main() {
    let mut a = 1;
    println!("{a}");
    a = increment(a);
    println!("{a}");
}
1
2