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 @@ -624,15 +624,10 @@ let x = (let y = 5i); // found `let` in ident position
624
624
The compiler is telling us here that it was expecting to see the beginning of
625
625
an expression, and a ` let ` can only begin a statement, not an expression.
626
626
627
- However, assigning to a variable binding is an expression:
628
-
629
- ``` {rust}
630
- let x;
631
- let y = x = 5i;
632
- ```
633
-
634
- In this case, we have an assignment expression (` x = 5 ` ) whose value is
635
- being used as part of a ` let ` declaration statement (` let y = ... ` ).
627
+ Note that assigning to an already-bound variable (e.g. ` y = 5i ` ) is still an
628
+ expression, although its value is not particularly useful. Unlike C, where an
629
+ assignment evaluates to the assigned value (e.g. ` 5i ` in the previous example),
630
+ in Rust the value of an assignment is the unit type ` () ` (which we'll cover later).
636
631
637
632
The second kind of statement in Rust is the ** expression statement** . Its
638
633
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