Regarding the issue of operator priority

rustc 1.82.0 (f6e511eec 2024-10-15)

println!("{}", 100 as u32 + (0 as u32) << 8);

Result:25600

Yes, + has stronger precedence than <<.

Also, clippy can help avoid surprises

warning: operator precedence can trip the unwary
 --> src/main.rs:2:20
  |
2 |     println!("{}", 100 as u32 + (0 as u32) << 8);
  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(100 as u32 + (0 as u32)) << 8`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
  = note: `#[warn(clippy::precedence)]` on by default
1 Like

You are right, thanks