Skip to content

improve formatting of boolean expression with groups #3108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
scampi opened this issue Oct 15, 2018 · 0 comments
Open

improve formatting of boolean expression with groups #3108

scampi opened this issue Oct 15, 2018 · 0 comments

Comments

@scampi
Copy link
Contributor

scampi commented Oct 15, 2018

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants