|
10 | 10 | > | _IfExpression_ |
11 | 11 | > | _IfLetExpression_ ) )<sup>\?</sup> |
12 | 12 |
|
13 | | -An `if` expression is a conditional branch in program control. The form of an |
14 | | -`if` expression is a condition expression, followed by a consequent block, any |
| 13 | +An `if` expression is a conditional branch in program control. The syntax of an |
| 14 | +`if` expression is a condition operand, followed by a consequent block, any |
15 | 15 | number of `else if` conditions and blocks, and an optional trailing `else` |
16 | | -block. The condition expressions must have type `bool`. If a condition |
17 | | -expression evaluates to `true`, the consequent block is executed and any |
18 | | -subsequent `else if` or `else` block is skipped. If a condition expression |
| 16 | +block. The condition operands must have the [boolean type]. If a condition |
| 17 | +operand evaluates to `true`, the consequent block is executed and any |
| 18 | +subsequent `else if` or `else` block is skipped. If a condition operand |
19 | 19 | evaluates to `false`, the consequent block is skipped and any subsequent `else |
20 | 20 | if` condition is evaluated. If all `if` and `else if` conditions evaluate to |
21 | 21 | `false` then any `else` block is executed. An if expression evaluates to the |
@@ -52,8 +52,8 @@ assert_eq!(y, "Bigger"); |
52 | 52 | > | _IfLetExpression_ ) )<sup>\?</sup> |
53 | 53 |
|
54 | 54 | An `if let` expression is semantically similar to an `if` expression but in |
55 | | -place of a condition expression it expects the keyword `let` followed by a |
56 | | -pattern, an `=` and a [scrutinee] expression. If the value of the scrutinee |
| 55 | +place of a condition operand it expects the keyword `let` followed by a |
| 56 | +pattern, an `=` and a [scrutinee] operand. If the value of the scrutinee |
57 | 57 | matches the pattern, the corresponding block will execute. Otherwise, flow |
58 | 58 | proceeds to the following `else` block if it exists. Like `if` expressions, |
59 | 59 | `if let` expressions have a value determined by the block that is evaluated. |
@@ -158,4 +158,5 @@ if let PAT = ( EXPR || EXPR ) { .. } |
158 | 158 | [_MatchArmPatterns_]: match-expr.md |
159 | 159 | [_eRFCIfLetChain_]: https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md#rollout-plan-and-transitioning-to-rust-2018 |
160 | 160 | [`match` expression]: match-expr.md |
| 161 | +[boolean type]: ../types/boolean.md |
161 | 162 | [scrutinee]: ../glossary.md#scrutinee |
0 commit comments