book
book copied to clipboard
is this the intended interpretation of the paragraph about a statement?
You give:
fn main() {
let x = plus_one(5);
println!("The value of x is: {x}");
}
fn plus_one(x: i32) -> i32 {
x + 1;
}
And then you clarify:
The definition of the function plus_one says that it will return an i32, but statements don’t evaluate to a value, which is expressed by
( ), the unit type.
The clause:
- statements don’t evaluate to a value, which is expressed by
( )
is unclear. ( ) is not a value, but the function is returning something.
Some definitions would help a lot.