Skip to content

Option to skip uneccessary match arm brackets #5351

Closed as not planned
Closed as not planned
@TheBlueMatt

Description

@TheBlueMatt

If rustfmt decides to indent after the => in a match (because the line ran too long) it also adds a {} and an extra line (for the }) even if the contents of the match arm fit onto a single line.

In the example at rust-bitcoin/rust-bitcoin#959 (comment) rustfmt generated

Error::SerializationError => {
    "can not serialize the spending transaction in Transaction::verify()"
},

when it arguably could have (optionally) just stuck with

Error::SerializationError =>
    "can not serialize the spending transaction in Transaction::verify()",

unlike ifs (and the C world) you can't get screwed by the lack of {} here - if you end up with two statements back-to-back its a compile error rather than incorrect logic.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions