Skip to content

Commit 29d4145

Browse files
hydhknnManishearth
authored andcommitted
Add while let to the reference
Closes rust-lang#17687
1 parent fa55858 commit 29d4145

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

reference.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3496,6 +3496,18 @@ of a condition expression it expects a refutable let statement. If the value of
34963496
expression on the right hand side of the let statement matches the pattern, the corresponding
34973497
block will execute, otherwise flow proceeds to the first `else` block that follows.
34983498

3499+
### While let loops
3500+
3501+
```{.ebnf .gram}
3502+
while_let_expr : "while" "let" pat '=' expr '{' block '}' ;
3503+
```
3504+
3505+
A `while let` loop is semantically identical to a `while` loop but in place of a
3506+
condition expression it expects a refutable let statement. If the value of the
3507+
expression on the right hand side of the let statement matches the pattern, the
3508+
loop body block executes and control returns to the pattern matching statement.
3509+
Otherwise, the while expression completes.
3510+
34993511
### Return expressions
35003512

35013513
```{.ebnf .gram}

0 commit comments

Comments
 (0)