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 integers to functions and returning integer

fn add_integers(x: i32, y: i32) -> i32 {
    let z = x + y;
    #[allow(clippy::needless_return)]
    return z;
}

fn main() {
    let a = 23;
    println!("{a}");

    let b = 19;
    println!("{b}");
    println!();

    let c = add_integers(a, b);
    println!("{a}");
    println!("{b}");
    println!("{c}");
}
23
19

23
19
42