Add match expression syntax and document feature(match_beginning_vert)#231
Conversation
| > _MatchBlock_ : | ||
| > `{` `}` | ||
| > | `{` (`|`<sup>?</sup> _Pattern_ (`|` _Pattern_)<sup>\*</sup> (`if` [_Expression_])<sup>?</sup> `=>` ([_BlockExpression_] `,`<sup>?</sup> | [_Expression_] `,`))<sup>\*</sup> | ||
| > (`|`<sup>?</sup> _Pattern_ (`|` _Pattern_)<sup>\*</sup> (`if` [_Expression_])<sup>?</sup> `=>` ([_BlockExpression_] `,`<sup>?</sup> | [_Expression_] `,`<sup>?</sup>)) |
There was a problem hiding this comment.
I was trying to line up the opening parenthesis with the one above it, but I couldn't quite line them up.
There was a problem hiding this comment.
This is correct, and it exists, and is better than anything, so I'm approving. 👍
But, with that said, there's a few things I don't like about this. The biggest is the duplication of the entire match clause for when there are multiple clauses. I'd rather a match clause be its own line (without the comma) and then MatchBlock would just be { _MatchClause_ (`,` _MatchClause_)<sup>*</sup> `,`<sup>?</sup> }.
|
If I understand your suggestion correctly, you mean this:
But if a MatchBlock has a non-final MatchClause with a BlockExpression on the right side of the |
…inning_vert, r=petrochenkov Stabilize feature(match_beginning_vert) With this feature stabilized, match expressions can optionally have a `|` at the beginning of each arm. Reference PR: rust-lang/reference#231 Closes rust-lang#44101
…inning_vert, r=petrochenkov Stabilize feature(match_beginning_vert) With this feature stabilized, match expressions can optionally have a `|` at the beginning of each arm. Reference PR: rust-lang/reference#231 Closes rust-lang#44101
…inning_vert, r=petrochenkov Stabilize feature(match_beginning_vert) With this feature stabilized, match expressions can optionally have a `|` at the beginning of each arm. Reference PR: rust-lang/reference#231 Closes rust-lang#44101
|
Thanks! |
Part of rust-lang/rust#47947