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 as wrapping_add.
  • Return the None value if there is overflow with the checked_* 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.