Skip to content

"short" config option for let-else statements? #5684

Closed
@calebcartwright

Description

@calebcartwright

Refs #4914

When the style team was discussing the formatting rules for let-else, an unsurprisingly key consideration was if/when/how the entire statement could be formatted on one line. As noted in the now-codified rules, there is a "if short enough" element to the required conditions for one-line formatting in the spirit of being consistent with other prescriptions in the current style guide edition.

Specifically https://github.com/rust-lang/rust/blob/master/src/doc/style-guide/src/statements.md#single-line-let-else-statements

With an intentional clause added to note the anticipated need for configurability in rustfmt:

Formatters may allow users to configure the value of the threshold used to determine whether a let-else statement is short.

Therefore the only real question IMO is: do we reuse an existing option, e.g. single_line_if_else_max_width, or do we introduce a new option, e.g. single_line_let_else_max_width), and if the latter then what should the default value be?

My inclination is to do the latter (largely based on past experiences of multi-use config options being insufficiently flexible and causing problems), likely with the same default value as single_line_if_else_max_width though I feel less strongly about this.

What are your thoughts @ytmimi?

cc @rust-lang/style for awareness

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