Skip to content

Commit 1ece005

Browse files
committed
trpl: why (assignment == empty tuple) #26120
1 parent 6c5834d commit 1ece005

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/doc/trpl/functions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ an expression, and a `let` can only begin a statement, not an expression.
144144
Note that assigning to an already-bound variable (e.g. `y = 5`) is still an
145145
expression, although its value is not particularly useful. Unlike other
146146
languages where an assignment evaluates to the assigned value (e.g. `5` in the
147-
previous example), in Rust the value of an assignment is an empty tuple `()`:
147+
previous example), in Rust the value of an assignment is an empty tuple `()`
148+
because the assigned value can have (just one owner)[ownership.html], and any
149+
other returned value would be too surprising:
148150

149151
```rust
150152
let mut y = 5;

0 commit comments

Comments
 (0)