Skip to content

Allow alternation within sub-patterns #17180

Closed
@mbrubeck

Description

@mbrubeck

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions