- saturating_add
Handle overflow and underflow - saturating
examples/numbers/handle-overflow-saturating/src/main.rs
fn main() { let mut num: i8 = 126; println!("{num}"); num = num.saturating_add(1); println!("{num}"); num = num.saturating_add(1); println!("{num}"); }
126 127 127