|
15 | 15 | > _MatchArm_ `=>` ( [_BlockExpression_] | [_Expression_] ) `,`<sup>?</sup>
|
16 | 16 | >
|
17 | 17 | > _MatchArm_ :\
|
18 |
| -> [_OuterAttribute_]<sup>\*</sup> _Patterns_ _MatchArmGuard_<sup>?</sup> |
| 18 | +> [_OuterAttribute_]<sup>\*</sup> _MatchArmPatterns_ _MatchArmGuard_<sup>?</sup> |
19 | 19 | >
|
20 |
| -> _Patterns_ :\ |
| 20 | +> _MatchArmPatterns_ :\ |
21 | 21 | > `|`<sup>?</sup> [_Pattern_] ( `|` [_Pattern_] )<sup>\*</sup>
|
22 | 22 | >
|
23 | 23 | > _MatchArmGuard_ :\
|
@@ -76,9 +76,8 @@ let message = match x {
|
76 | 76 | assert_eq!(message, "a few");
|
77 | 77 | ```
|
78 | 78 |
|
79 |
| -> Note: The `2..=9` is a [Range Pattern], not a [Range Expression] and, thus, |
80 |
| -> only those types of ranges supported by range patterns can be used in match |
81 |
| -> arms. |
| 79 | +> Note: The `2..=9` is a [Range Pattern], not a [Range Expression]. Thus, only |
| 80 | +> those types of ranges supported by range patterns can be used in match arms. |
82 | 81 |
|
83 | 82 | Every binding in each `|` separated pattern must appear in all of the patterns
|
84 | 83 | in the arm. Every binding of the same name must have the same type, and have
|
@@ -109,15 +108,13 @@ let message = match maybe_digit {
|
109 | 108 | > and side effects it has to execute multiple times. For example:
|
110 | 109 | >
|
111 | 110 | > ```rust
|
112 |
| -> use std::cell::Cell; |
113 |
| -> fn main() { |
114 |
| -> let i : Cell<i32> = Cell::new(0); |
115 |
| -> match 1 { |
116 |
| -> 1 | _ if { i.set(i.get() + 1); false } => {} |
117 |
| -> _ => {} |
118 |
| -> } |
119 |
| -> assert_eq!(i.get(), 2); |
| 111 | +> # use std::cell::Cell; |
| 112 | +> let i : Cell<i32> = Cell::new(0); |
| 113 | +> match 1 { |
| 114 | +> 1 | _ if { i.set(i.get() + 1); false } => {} |
| 115 | +> _ => {} |
120 | 116 | > }
|
| 117 | +> assert_eq!(i.get(), 2); |
121 | 118 | > ```
|
122 | 119 |
|
123 | 120 | ## Attributes on match arms
|
|
0 commit comments