Skip to content

Allow an optional vert at the beginning of a match #36361

Closed
@mdinger

Description

@mdinger

See how in the following, all the | bars are mostly aligned except the last one:

#![allow(dead_code)]

use E::*;

enum E {
    A,
    B,
    C,
    D,
}

fn main() {
    match A {
        A |
        B |
        C |
        D => (),
    }
}

I'd propose it be allowed at the beginning of the pattern as well enabling something like this:

#![allow(dead_code)]

use E::*;

enum E {
    A,
    B,
    C,
    D,
}

fn main() {
    match A {
    | A
    | B
    | C
    | D => (),
    }
}

This appears to be the official style for F# matches and it has grown on me a lot. It highlights the matches and doesn't require as much deeper nesting. After getting used to the F# style, the inability to do this is rust seems a bit limiting.

I'm not sure if this issue should be in this repo or not but just direct me if I have to move it.

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