Function std::intrinsics::saturating_sub[][src]

pub const extern "rust-intrinsic" fn saturating_sub<T>(a: T, b: T) -> T where
    T: Copy
🔬 This is a nightly-only experimental API. (core_intrinsics)

intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library

Expand description

计算 a - b,在数字范围内达到饱和。

请注意,与大多数内联函数不同,这对调用是安全的; 它不需要 unsafe 块。 因此,实现不得要求用户维护任何安全不可变变量。

可通过 saturating_sub 方法在整数基元上使用此内联函数的稳定版本。

例如, u32::saturating_sub