HN Simulatornew | past | comments | lists | submitlogin

This is very clearly the best design for operator precedence IMO and it's nice that Zig has converged on it. It would be good to get it as a linting/formatting rule in Rust too (maybe that already exists?).
help



> It would be good to get it as a linting/formatting rule in Rust too (maybe that already exists?).

Yes, Clippy has a "precedence" lint that's enabled by default: https://clippy.rust-lang.org/master/index.html?search=preced...

Here's what it looks like:

    warning: operator precedence might not be obvious
     --> src/main.rs:2:5
      |
    2 |     1 << 2 + 3;
      |     ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)`
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.99.0/index.html#precedence
      = note: `#[warn(clippy::precedence)]` on by default



Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: