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

Signature

pub trait SaturatingSub

Examples

use core::num::traits::SaturatingSub;

assert!(1_u8.saturating_sub(2_u8) == 0);

Trait functions

saturating_sub

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

Signature

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