Closed
Description
What it does
The lint flags for wrapping/saturating div/rem/rem_euclid functions on signed and unsigned integer types. These functions cover one edge case for signed types and do nothing special for unsigned types. The other edge case of rhs
being zero is not covered by either of them so the function may still panic on division by zero. The arithmetic_side_effects
doesn't flag against them, maybe this should be integrated into that lint.
Lint Name
No response
Category
restriction
Advantage
Flags against potentially panicking arithmetic operations that may be used to circumvent the arithmetic_side_effects
lint.
Drawbacks
No response
Example
let x = 10i32;
x.wrapping_div(0);
Will panic with a division by zero error.
The recommendation would be:
let x = 10i32;
x.checked_div(0); // Work with the Option
The same goes for rem
and rem_euclid