Rust function return value (integer i32)
-
return
-
i32
-
After an arrow
->
we can add the type of the return value. -
We can then return that value by using the
return
statement. -
#[allow(clippy::needless_return)]
is there to silence clippy, the linter.
fn main() { println!("{}", add(2, 3)); println!("{}", add(3, 4)); } fn add(x: i32, y: i32) -> i32 { #[allow(clippy::needless_return)] return x + y; }