book icon indicating copy to clipboard operation
book copied to clipboard

is this the intended interpretation of the paragraph about a statement?

Open iampi31415 opened this issue 4 months ago • 15 comments

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.

iampi31415 avatar May 31 '25 13:05 iampi31415