|
2 | 2 |
|
3 | 3 | > **<sup>Syntax</sup>**
|
4 | 4 | > _MatchExpression_ :
|
5 |
| -> `match` [_Expression_]<sub>_except struct expression_</sub> _MatchBlock_ |
| 5 | +> `match` [_Expression_]<sub>_except struct expression_</sub> `{` |
| 6 | +> [_InnerAttribute_]<sup>\*</sup> |
| 7 | +> _MatchArms_<sup>?</sup> |
| 8 | +> `}` |
6 | 9 | >
|
7 |
| -> _MatchBlock_ : |
8 |
| -> `{` `}` |
9 |
| -> | `{` (`|`<sup>?</sup> _Pattern_ (`|` _Pattern_)<sup>\*</sup> (`if` [_Expression_])<sup>?</sup> `=>` ([_BlockExpression_] `,`<sup>?</sup> | [_Expression_] `,`))<sup>\*</sup> |
10 |
| -> (`|`<sup>?</sup> _Pattern_ (`|` _Pattern_)<sup>\*</sup> (`if` [_Expression_])<sup>?</sup> `=>` ([_BlockExpression_] `,`<sup>?</sup> | [_Expression_] `,`<sup>?</sup>)) |
11 |
| -> `}` |
| 10 | +> _MatchArms_ : |
| 11 | +> ( _MatchArm_ `=>` |
| 12 | +> ( [_BlockExpression_] `,`<sup>?</sup> |
| 13 | +> | [_Expression_] `,` ) |
| 14 | +> )<sup>\*</sup> |
| 15 | +> _MatchArm_ `=>` ( [_BlockExpression_] | [_Expression_] ) `,`<sup>?</sup> |
| 16 | +> |
| 17 | +> _MatchArm_ : |
| 18 | +> [_OuterAttribute_]<sup>\*</sup> _MatchArmPatterns_ _MatchArmGuard_ |
| 19 | +> |
| 20 | +> _MatchArmPatterns_ : |
| 21 | +> `|`<sup>?</sup> _Pattern_ ( `|` _Pattern_ )<sup>*</sup> |
| 22 | +> |
| 23 | +> _MatchArmGuard_ : |
| 24 | +> `if` [_Expression_] |
12 | 25 |
|
13 | 26 | A `match` expression branches on a *pattern*. The exact form of matching that
|
14 | 27 | occurs depends on the pattern. Patterns consist of some combination of
|
@@ -141,4 +154,6 @@ let message = match maybe_digit {
|
141 | 154 | [place expression]: expressions.html#place-expressions-and-value-expressions
|
142 | 155 | [value expression]: expressions.html#place-expressions-and-value-expressions
|
143 | 156 | [`char`]: types.html#textual-types
|
144 |
| -[numeric types]: types.html#numeric-types |
| 157 | +[numeric types]: types.html#numeric-types |
| 158 | +[_InnerAttribute_]: attributes.html |
| 159 | +[_OuterAttribute_]: attributes.html |
0 commit comments