File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -684,15 +684,10 @@ let x = (let y = 5i); // found `let` in ident position
684
684
The compiler is telling us here that it was expecting to see the beginning of
685
685
an expression, and a ` let ` can only begin a statement, not an expression.
686
686
687
- However, assigning to a variable binding is an expression:
688
-
689
- ``` {rust}
690
- let x;
691
- let y = x = 5i;
692
- ```
693
-
694
- In this case, we have an assignment expression (` x = 5 ` ) whose value is
695
- being used as part of a ` let ` declaration statement (` let y = ... ` ).
687
+ Note that assigning to an already-bound variable (e.g. ` y = 5i ` ) is still an
688
+ expression, although its value is not particularly useful. Unlike C, where an
689
+ assignment evaluates to the assigned value (e.g. ` 5i ` in the previous example),
690
+ in Rust the value of an assignment is the unit type ` () ` (which we'll cover later).
696
691
697
692
The second kind of statement in Rust is the ** expression statement** . Its
698
693
purpose is to turn any expression into a statement. In practical terms, Rust's
You can’t perform that action at this time.
0 commit comments