Rust

Rust

Made by DeepSource

Found trivial or undefined modulus operation RS-W1005

Bug risk
Minor

The remainder of a division by 1 is always 0. On the other hand, the remainder of a division by -1 is may cause panics/overflows if the dividend is the lower bound of its integral type.

Expressions of the type x % 1 or x % -1 require an audit.

Bad practice

let x = i32::MIN;
let _ = x % 1;  // always 0
let _ = x % -1; // arithmetic overflow