File tree 1 file changed +23
-1
lines changed
1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ assert_eq!(y, "Bigger");
44
44
45
45
> ** <sup >Syntax</sup >** \
46
46
> _ IfLetExpression_ :\
47
- >   ;  ; ` if ` ` let ` [ _ Pattern_ ] ` = ` [ _ Expression_ ] <sub >_ except struct expression_ </sub >
47
+ >   ;  ; ` if ` ` let ` [ _ Pattern_ ] ` = ` [ _ Expression_ ] <sub >_ except struct or lazy boolean operator expression_ </sub >
48
48
> [ _ BlockExpression_ ] \
49
49
>   ;  ; (` else ` (
50
50
> [ _ BlockExpression_ ]
@@ -111,6 +111,28 @@ match EXPR {
111
111
}
112
112
```
113
113
114
+ The expression cannot be a [ lazy boolean operator expression] [ _LazyBooleanOperatorExpression_ ] .
115
+ Use of a lazy boolean operator is ambiguous with a planned feature change
116
+ 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
+ ```
133
+
114
134
[ _Expression_ ] : expressions.html
115
135
[ _BlockExpression_ ] : expressions/block-expr.html
116
136
[ _Pattern_ ] : patterns.html
137
+ [ _LazyBooleanOperatorExpression_ ] : expressions/operator-expr.html#lazy-boolean-operators
138
+ [ _eRFCIfLetChain_ ] : https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md#rollout-plan-and-transitioning-to-rust-2018
You can’t perform that action at this time.
0 commit comments