pub trait CheckedSubUnsigned: Sized {
type Unsigned;
type Output;
// Required method
fn checked_sub_unsigned(self, rhs: Self::Unsigned) -> Option<Self::Output>;
}Expand description
Checked subtraction of an unsigned value from a signed value.
Required Associated Types§
Required Methods§
Sourcefn checked_sub_unsigned(self, rhs: Self::Unsigned) -> Option<Self::Output>
fn checked_sub_unsigned(self, rhs: Self::Unsigned) -> Option<Self::Output>
Computes self - rhs, returning None if overflow occurred.
use const_num_traits::CheckedSubUnsigned;
assert_eq!(CheckedSubUnsigned::checked_sub_unsigned(1i8, 2), Some(-1));
assert_eq!(CheckedSubUnsigned::checked_sub_unsigned(i8::MIN, 1), None);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".