Skip to content

Commit 9f758ac

Browse files
committed
Mention a solution for eRFC 2947 ambiguity.
1 parent 165c11a commit 9f758ac

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/expressions/if-expr.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,22 @@ match EXPR {
114114
The expression cannot be a [lazy boolean operator expression][_LazyBooleanOperatorExpression_].
115115
Use of a lazy boolean operator is ambiguous with a planned feature change
116116
of the language (the implementation of if-let chains - see [eRFC 2947][_eRFCIfLetChain_]).
117+
When lazy boolean operator expression is desired, this can be achieved
118+
by using parenthesis as below:
119+
120+
```rust,ignore
121+
// Before...
122+
if let PAT = EXPR && EXPR { .. }
123+
124+
// After...
125+
if let PAT = ( EXPR && EXPR ) { .. }
126+
127+
// Before...
128+
if let PAT = EXPR || EXPR { .. }
129+
130+
// After...
131+
if let PAT = ( EXPR || EXPR ) { .. }
132+
```
117133

118134
[_Expression_]: expressions.html
119135
[_BlockExpression_]: expressions/block-expr.html

0 commit comments

Comments
 (0)