Skip to content

improve formatting of boolean expression with groups #3108

Open
@scampi

Description

@scampi

I think the formatting of the following boolean expression could be improved so that it is clear that:

  • the first two operands are OR'ed
  • and its result is AND'ed with the third operand.

https://github.com/rust-lang-nursery/rustfmt/blob/075aa909cd2bcdc603f45e0b65119c6a7e3b2030/src/expr.rs#L886-L888

A possible formatting would be:

let force_newline_brace =
    (pat_expr_string.contains('\n') || pat_expr_string.len() > one_line_budget) 
        && !last_line_extendable(&pat_expr_string);

If there is not enough space, we could have something like:

let force_newline_brace =
    (pat_expr_string12345678.contains('\n')
     || pat_expr_string123456789.len() > one_line_budget) 
        && !last_line_extendable(&pat_expr_string);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions