Skip to content

Less ideal formatting for struct pattern matching in if let #3560

@upsuper

Description

@upsuper

Given the following code:

struct Foo {
    something: Option<u32>,
    bar: u32,
}

fn main() {
    let a = Foo {
        something: Some(1),
        bar: 2,
    };
    if let Foo { something: Some(something), .. } = a {
        println!("{}", something);
    }
}

rustfmt formats the if let as

    if let Foo {
        something: Some(something),
        ..
    } = a
    {
        println!("{}", something);
    }

which looks rather unfortunate...

Should probably keep the original form in this case?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions