Skip to content

Commit

Permalink
Merge pull request rust-lang#231 from goodmanjonathan/match_beginning…
Browse files Browse the repository at this point in the history
…_vert

Add match expression syntax and document feature(match_beginning_vert)
  • Loading branch information
matthewjasper authored Feb 6, 2018
2 parents e2d1ee5 + cad98d1 commit 55893bf
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/expressions/match-expr.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# `match` expressions

> **<sup>Syntax</sup>**
> _MatchExpression_ :
> &nbsp;&nbsp; `match` [_Expression_]<sub>_except struct expression_</sub> _MatchBlock_
>
> _MatchBlock_ :
> &nbsp;&nbsp; &nbsp;&nbsp; `{` `}`
> &nbsp;&nbsp; | `{` (`|`<sup>?</sup> _Pattern_ (`|` _Pattern_)<sup>\*</sup> (`if` [_Expression_])<sup>?</sup> `=>` ([_BlockExpression_] `,`<sup>?</sup> | [_Expression_] `,`))<sup>\*</sup>
> &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; (`|`<sup>?</sup> _Pattern_ (`|` _Pattern_)<sup>\*</sup> (`if` [_Expression_])<sup>?</sup> `=>` ([_BlockExpression_] `,`<sup>?</sup> | [_Expression_] `,`<sup>?</sup>))
> &nbsp;&nbsp; &nbsp;&nbsp; `}`
A `match` expression branches on a *pattern*. The exact form of matching that
occurs depends on the pattern. Patterns consist of some combination of
literals, destructured arrays or enum constructors, structs and tuples,
Expand Down Expand Up @@ -127,5 +137,7 @@ let message = match maybe_digit {
};
```

[_Expression_]: expressions.html
[_BlockExpression_]: expressions/block-expr.html#block-expressions
[place expression]: expressions.html#place-expressions-and-value-expressions
[value expression]: expressions.html#place-expressions-and-value-expressions
[value expression]: expressions.html#place-expressions-and-value-expressions

0 comments on commit 55893bf

Please sign in to comment.