Trait option_operations::sub::OptionSaturatingSub
source · pub trait OptionSaturatingSub<Rhs = Self, InnerRhs = Rhs> {
type Output;
// Required method
fn opt_saturating_sub(self, rhs: Rhs) -> Option<Self::Output>;
}
Expand description
Trait for values and Option
s saturating substraction.
Implementing this trait leads to the following auto-implementations:
OptionSaturatingSub<Option<InnerRhs>>
forT
.OptionSaturatingSub<Rhs>
forOption<T>
.OptionSaturatingSub<Option<InnerRhs>>
forOption<T>
.- … and some variants with references.
Note that since the std
library doesn’t define any
SaturatingSub
trait,
users must provide the base implementation for the inner type.
Required Associated Types§
Required Methods§
sourcefn opt_saturating_sub(self, rhs: Rhs) -> Option<Self::Output>
fn opt_saturating_sub(self, rhs: Rhs) -> Option<Self::Output>
Computes the substraction saturating at the numeric bounds instead of overflowing.
Returns None
if at least one argument is None
.