提交 e53f4a6b 编写于 作者: J Jakub Wieczorek

Add `if let` to the reference

上级 13e00e4a
......@@ -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}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册