Add if let
to the reference
This commit is contained in:
parent
13e00e4a3d
commit
e53f4a6b94
@ -3231,7 +3231,7 @@ for i in range(0u, 256) {
|
||||
if_expr : "if" no_struct_literal_expr '{' block '}'
|
||||
else_tail ? ;
|
||||
|
||||
else_tail : "else" [ if_expr
|
||||
else_tail : "else" [ if_expr | if_let_expr
|
||||
| '{' block '}' ] ;
|
||||
```
|
||||
|
||||
@ -3436,6 +3436,19 @@ let message = match maybe_digit {
|
||||
};
|
||||
```
|
||||
|
||||
### If let expressions
|
||||
|
||||
```{.ebnf .gram}
|
||||
if_let_expr : "if" "let" pat '=' expr '{' block '}'
|
||||
else_tail ? ;
|
||||
else_tail : "else" [ if_expr | if_let_expr | '{' block '}' ] ;
|
||||
```
|
||||
|
||||
An `if let` expression is semantically identical to an `if` expression but in place
|
||||
of a condition expression it expects a refutable let statement. If the value of the
|
||||
expression on the right hand side of the let statement matches the pattern, the corresponding
|
||||
block will execute, otherwise flow proceeds to the first `else` block that follows.
|
||||
|
||||
### Return expressions
|
||||
|
||||
```{.ebnf .gram}
|
||||
|
Loading…
Reference in New Issue
Block a user