Module malachite_base::num::arithmetic::saturating_add
source · Expand description
SaturatingAdd
and
SaturatingAddAssign
, traits for adding two numbers and
saturating at numeric bounds instead of overflowing.
§saturating_add_assign
use malachite_base::num::arithmetic::traits::SaturatingAddAssign;
let mut x = 123u16;
x.saturating_add_assign(456);
assert_eq!(x, 579);
let mut x = 123u8;
x.saturating_add_assign(200);
assert_eq!(x, 255);