diff --git a/src/expressions/if-expr.md b/src/expressions/if-expr.md index 591437fc9..30412d8f5 100644 --- a/src/expressions/if-expr.md +++ b/src/expressions/if-expr.md @@ -4,11 +4,21 @@ > **Syntax**\ > _IfExpression_ :\ ->    `if` [_Expression_]_except struct expression_ [_BlockExpression_]\ ->    (`else` ( +>    `if` _inIfList_ [_BlockExpression_]\ +>    ( `else` ( > [_BlockExpression_] > | _IfExpression_ > | _IfLetExpression_ ) )\? +> +> _inIf_ :\ +>    ( `let` [_Pattern_] `=` [_Expression_]_except struct expression_ +> | [_Expression_]_except struct expression_ +> | _inIf_ ) +> +> _inIfList_ :\ +>    _inIf_ ( && _inIf_ )* + +[_Expression_]_except struct expression_ An `if` expression is a conditional branch in program control. 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 { ``` The expression cannot be a [lazy boolean operator expression][_LazyBooleanOperatorExpression_]. -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_]). When lazy boolean operator expression is desired, this can be achieved by using parenthesis as below: @@ -149,7 +158,6 @@ if let PAT = ( EXPR || EXPR ) { .. } [_LazyBooleanOperatorExpression_]: operator-expr.md#lazy-boolean-operators [_Pattern_]: ../patterns.md [_Scrutinee_]: match-expr.md -[_eRFCIfLetChain_]: https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md#rollout-plan-and-transitioning-to-rust-2018 [`match` expression]: match-expr.md [boolean type]: ../types/boolean.md [scrutinee]: ../glossary.md#scrutinee