Skip to content

Commit 514d8b3

Browse files
committed
Add let_chains references
1 parent 0a2fe66 commit 514d8b3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/expressions/if-expr.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@
44

55
> **<sup>Syntax</sup>**\
66
> _IfExpression_ :\
7-
> &nbsp;&nbsp; `if` [_Expression_]<sub>_except struct expression_</sub> [_BlockExpression_]\
8-
> &nbsp;&nbsp; (`else` (
7+
> &nbsp;&nbsp; `if` _inIfList_ [_BlockExpression_]\
8+
> &nbsp;&nbsp; ( `else` (
99
> [_BlockExpression_]
1010
> | _IfExpression_
1111
> | _IfLetExpression_ ) )<sup>\?</sup>
12+
>
13+
> _inIf_ :\
14+
> &nbsp;&nbsp; ( `let` [_Pattern_] `=` [_Expression_]<sub>_except struct expression_</sub>
15+
> | [_Expression_]<sub>_except struct expression_</sub>
16+
> | _inIf_ )
17+
>
18+
> _inIfList_ :\
19+
> &nbsp;&nbsp; _inIf_ ( && _inIf_ )*
20+
21+
[_Expression_]<sub>_except struct expression_</sub>
1222

1323
An `if` expression is a conditional branch in program control.
1424
The syntax of an `if` expression is a condition operand, followed by a consequent block, any number of `else if` conditions and blocks, and an optional trailing `else` block.
@@ -126,7 +136,6 @@ if let E::X(n) | E::Y(n) = v {
126136
```
127137

128138
The expression cannot be a [lazy boolean operator expression][_LazyBooleanOperatorExpression_].
129-
Use of a lazy boolean operator is ambiguous with a planned feature change of the language (the implementation of if-let chains - see [eRFC 2947][_eRFCIfLetChain_]).
130139
When lazy boolean operator expression is desired, this can be achieved by using parenthesis as below:
131140

132141
<!-- ignore: psuedo code -->
@@ -149,7 +158,6 @@ if let PAT = ( EXPR || EXPR ) { .. }
149158
[_LazyBooleanOperatorExpression_]: operator-expr.md#lazy-boolean-operators
150159
[_Pattern_]: ../patterns.md
151160
[_Scrutinee_]: match-expr.md
152-
[_eRFCIfLetChain_]: https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md#rollout-plan-and-transitioning-to-rust-2018
153161
[`match` expression]: match-expr.md
154162
[boolean type]: ../types/boolean.md
155163
[scrutinee]: ../glossary.md#scrutinee

0 commit comments

Comments
 (0)