Performs addition that saturates at the numeric bounds instead of overflowing.

Signature

pub trait SaturatingAdd

Examples

use core::num::traits::SaturatingAdd;

assert!(255_u8.saturating_add(1_u8) == 255);

Trait functions

saturating_add

Saturating addition. Computes self + other, saturating at the relevant high or low boundary of the type.

Signature

fn saturating_add(self: T, other: T) -> T