Skip to content
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

Allow nested alternatives in patterns #9663

Closed
ben0x539 opened this issue Oct 1, 2013 · 3 comments
Closed

Allow nested alternatives in patterns #9663

ben0x539 opened this issue Oct 1, 2013 · 3 comments
Labels
A-frontend Area: frontend (errors, parsing and HIR) A-grammar Area: The grammar of Rust C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@ben0x539
Copy link
Contributor

ben0x539 commented Oct 1, 2013

Feature request to allow, like,

match Some(42) {
    Some(1 | 2 | 3 | 42) => 0,
    _ => 1
}

instead of

Some(1) | Some(2) | Some(3) | Some(42) => 0, 

Makes it easier to match a few inner different values deep within a common outer structure and seems like a logical extension of the existing syntax.

This might make the visual ambiguity with the binary bitwise-or | more pronounced, though.

@catamorphism
Copy link
Contributor

I've wanted this sometimes, but the pattern-matching code is scary, so I'm not sure how easy it would be to implement. (I'm guessing not easy.)

@ben0x539
Copy link
Contributor Author

ben0x539 commented Oct 1, 2013

(note+ping, I forgot to add I filed this because @erickt said he was interested in adding the feature)

@Aatch
Copy link
Contributor

Aatch commented Mar 23, 2014

If anybody is still interested in this, an official RFC should be filed. https://github.com/rust-lang/rfcs/blob/master/active/0001-rfc-process.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: frontend (errors, parsing and HIR) A-grammar Area: The grammar of Rust C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

3 participants