When compiling a program in debug mode, Rust add checks for integer overflows that will panic if it occurs.
In --release mode, this check does not exist. The integer will overflow.
Methods of handling integer overflows include:
- Wrap in all modes with the
wrapping_*methods, such aswrapping_add. - Return the
Nonevalue if there is overflow with thechecked_*methods. - Return the value and a Boolean indicating whether there was overflow with the
overflowing_*methods. - Saturate at the value’s minimum or maximum values with the
saturating_*methods.