@@ -53,11 +53,10 @@ assert_eq!(y, "Bigger");
53
53
54
54
An ` if let ` expression is semantically similar to an ` if ` expression but in
55
55
place of a condition expression it expects the keyword ` let ` followed by a
56
- pattern, an ` = ` and an expression. If the value of the expression on the right
57
- hand side of the ` = ` matches the pattern, the corresponding block will
58
- execute, otherwise flow proceeds to the following ` else ` block if it exists.
59
- Like ` if ` expressions, ` if let ` expressions have a value determined by the
60
- block that is evaluated.
56
+ pattern, an ` = ` and a [ scrutinee] expression. If the value of the scrutinee
57
+ matches the pattern, the corresponding block will execute. Otherwise, flow
58
+ proceeds to the following ` else ` block if it exists. Like ` if ` expressions,
59
+ ` if let ` expressions have a value determined by the block that is evaluated.
61
60
62
61
``` rust
63
62
let dish = (" Ham" , " Eggs" );
@@ -75,8 +74,6 @@ if let ("Ham", b) = dish {
75
74
println! (" Ham is served with {}" , b );
76
75
}
77
76
78
- // Irrefutable patterns are allowed primarily to make it easier for macros to
79
- // accept any kind of pattern.
80
77
if let _ = 5 {
81
78
println! (" Irrefutable patterns are always true" );
82
79
}
@@ -142,3 +139,4 @@ if let PAT = ( EXPR || EXPR ) { .. }
142
139
[ _Pattern_ ] : patterns.html
143
140
[ _LazyBooleanOperatorExpression_ ] : expressions/operator-expr.html#lazy-boolean-operators
144
141
[ _eRFCIfLetChain_ ] : https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md#rollout-plan-and-transitioning-to-rust-2018
142
+ [ scrutinee ] : glossary.html#scrutinee
0 commit comments