-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add match expression syntax and document feature(match_beginning_vert) #231
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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