Expressions vs statements
The last expression in a block (without ;) is the return value. Add a semicolon and you get () — the unit type. The semicolon trap has humbled many.
fn add(a: i32, b: i32) -> i32 {
a + b
}Output
Press Run to execute your code.