pub trait CheckedSub<T>: Sized {
type Output;
// Required method
fn checked_sub(&self, rhs: T) -> Option<Self::Output>;
}Expand description
Safe subtraction.
Required Associated Types§
Required Methods§
Sourcefn checked_sub(&self, rhs: T) -> Option<Self::Output>
fn checked_sub(&self, rhs: T) -> Option<Self::Output>
Subtracts two items.
- If the subtraction occurs successfully, then
Some<Self>is returned. - If the subtraction would overflow,
Noneis returned.
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.