@@ -10,17 +10,19 @@ r[expr.if.syntax]
10
10
>   ;  ; (` else ` ( [ _ BlockExpression_ ] | _ IfExpression_ ) )<sup >\? </sup >
11
11
>
12
12
> _ IfConditions_ :\
13
- >   ;  ; _ IfCondition_ ( && _ IfCondition_ )*
13
+ >   ;  ; _ IfCondition_ ( && _ IfCondition_ )* [ ^ if-condition-2024 ]
14
14
>
15
15
> _ IfCondition_ :\
16
- >   ;  ;   ;  ; [ _ Expression_ ] <sub >_ except struct expression_ </sub >\
17
- >   ;  ; | ` let ` [ _ Pattern_ ] ` = ` [ _ Scrutinee_ ]
16
+ >   ;  ;   ;  ; [ _ Expression_ ] <sub >_ except struct expression or lazy boolean expression_ </sub >\
17
+ >   ;  ; | ` let ` [ _ Pattern_ ] ` = ` [ _ Scrutinee_ ] <sub >_ except struct expression or lazy boolean expression_ </sub >
18
+ >
19
+ > [ ^ if-condition-2024 ] : Editions before 2024 only allow a single _ IfCondition_ .
18
20
19
21
r[ expr.if.intro]
20
22
The syntax of an ` if ` expression is a sequence of one or more condition operands separated by ` && ` ,
21
23
followed by a consequent block, any number of ` else if ` conditions and blocks, and an optional trailing ` else ` block.
22
24
23
- r[ expr.if.condition-bool ]
25
+ r[ expr.if.condition]
24
26
Condition operands must be either an [ _ Expression_ ] with a [ boolean type] or a conditional ` let ` match.
25
27
26
28
r[ expr.if.condition-true]
@@ -160,6 +162,9 @@ If a `||` expression is needed, then parentheses can be used. For example:
160
162
if let Some (x ) = foo && (condition1 || condition2 ) { /*...*/ }
161
163
```
162
164
165
+ r[ expr.if.edition2024]
166
+ > ** Edition differences** : Before the 2024 edition, let chains are not supported and only a single _ IfCondition_ is allowed in an ` if ` expression.
167
+
163
168
[ _BlockExpression_ ] : block-expr.md
164
169
[ _Expression_ ] : ../expressions.md
165
170
[ _LazyBooleanOperatorExpression_ ] : operator-expr.md#lazy-boolean-operators
0 commit comments