Skip to content

Commit cb09001

Browse files
committed
Rollup merge of rust-lang#22307 - steveklabnik:gh14849, r=huonw
Fixes rust-lang#14849
2 parents 70647ec + 148d90b commit cb09001

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/doc/reference.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,9 +2742,19 @@ items can bring new names into scopes and declared items are in scope for only
27422742
the block itself.
27432743

27442744
A block will execute each statement sequentially, and then execute the
2745-
expression (if given). If the final expression is omitted, the type and return
2746-
value of the block are `()`, but if it is provided, the type and return value
2747-
of the block are that of the expression itself.
2745+
expression (if given). If the block ends in a statement, its value is `()`:
2746+
2747+
```
2748+
let x: () = { println!("Hello."); };
2749+
```
2750+
2751+
If it ends in an expression, its value and type are that of the expression:
2752+
2753+
```
2754+
let x: i32 = { println!("Hello."); 5 };
2755+
2756+
assert_eq!(5, x);
2757+
```
27482758

27492759
### Method-call expressions
27502760

0 commit comments

Comments
 (0)