pub trait CheckedSub: Sub + Sized {
// Required method
fn checked_sub(self, rhs: Self) -> Option<Self>;
}
Expand description
Performs checked substraction. Maps directly to the integers checked_sub method. (i.e.
u8::checked_sub
) Consult the docs of the primitive methods to learn more.
Required Methods§
Sourcefn checked_sub(self, rhs: Self) -> Option<Self>
fn checked_sub(self, rhs: Self) -> Option<Self>
performs checked sub
§Example
let a = 2u8;
let b = 1u8;
assert_eq!(CheckedSub::checked_sub(a, b), a.checked_sub(b));
assert_eq!(CheckedSub::checked_sub(b, a), b.checked_sub(a));
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.