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 alternation within sub-patterns #17180

Closed
mbrubeck opened this issue Sep 11, 2014 · 6 comments
Closed

Allow alternation within sub-patterns #17180

mbrubeck opened this issue Sep 11, 2014 · 6 comments

Comments

@mbrubeck
Copy link
Contributor

Allowing | to be used within a sub-pattern would allow some match expressions on tuples and structs to be written much more clearly and concisely.

For example, the following match expression:

match (x, y) {
    (A|B, C|D) => 0,
    _ => 1
}

would be equivalent to this expanded version:

match (x, y) {
    (A, C) => 0,
    (A, D) => 0,
    (B, C) => 0,
    (B, D) => 0,
    _ => 1
}
@ftxqxd
Copy link
Contributor

ftxqxd commented Sep 12, 2014

rust-lang/rfcs#99 proposed such an addition (among other things), but was postponed until post-1.0.

@alexcrichton
Copy link
Member

As @P1start mentioned, this is currently a postponed RFC, so I'm closing in favor of that.

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Jul 8, 2017

rust-lang/rfcs#1882 is a more recent version of this request

@mbrubeck
Copy link
Contributor Author

mbrubeck commented May 21, 2018

rust-lang/rfcs#2175 addresses part of this feature.

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Sep 26, 2018

New RFC for this feature: rust-lang/rfcs#2535.

@mbrubeck
Copy link
Contributor Author

mbrubeck commented May 3, 2021

Update: RFC 2535 was implemented and will become stable in Rust 1.53.

lnicola pushed a commit to lnicola/rust that referenced this issue May 19, 2024
minor: bump `peaceiris/actions-gh-pages`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants