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 Options saturating substraction.

Implementing this trait leads to the following auto-implementations:

  • OptionSaturatingSub<Option<InnerRhs>> for T.
  • OptionSaturatingSub<Rhs> for Option<T>.
  • OptionSaturatingSub<Option<InnerRhs>> for Option<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§

source

type Output

The resulting inner type after applying the substraction.

Required Methods§

source

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.

Implementations on Foreign Types§

source§

impl OptionSaturatingSub for i8

source§

type Output = i8

source§

fn opt_saturating_sub(self, rhs: Self) -> Option<Self::Output>

source§

impl OptionSaturatingSub for i16

source§

type Output = i16

source§

fn opt_saturating_sub(self, rhs: Self) -> Option<Self::Output>

source§

impl OptionSaturatingSub for i32

source§

type Output = i32

source§

fn opt_saturating_sub(self, rhs: Self) -> Option<Self::Output>

source§

impl OptionSaturatingSub for i64

source§

type Output = i64

source§

fn opt_saturating_sub(self, rhs: Self) -> Option<Self::Output>

source§

impl OptionSaturatingSub for i128

source§

type Output = i128

source§

fn opt_saturating_sub(self, rhs: Self) -> Option<Self::Output>

source§

impl OptionSaturatingSub for u8

source§

type Output = u8

source§

fn opt_saturating_sub(self, rhs: Self) -> Option<Self::Output>

source§

impl OptionSaturatingSub for u16

source§

type Output = u16

source§

fn opt_saturating_sub(self, rhs: Self) -> Option<Self::Output>

source§

impl OptionSaturatingSub for u32

source§

type Output = u32

source§

fn opt_saturating_sub(self, rhs: Self) -> Option<Self::Output>

source§

impl OptionSaturatingSub for u64

source§

type Output = u64

source§

fn opt_saturating_sub(self, rhs: Self) -> Option<Self::Output>

source§

impl OptionSaturatingSub for u128

source§

type Output = u128

source§

fn opt_saturating_sub(self, rhs: Self) -> Option<Self::Output>

source§

impl OptionSaturatingSub for Duration

source§

type Output = Duration

source§

fn opt_saturating_sub(self, rhs: Self) -> Option<Self::Output>

source§

impl<T, InnerRhs> OptionSaturatingSub<&Option<InnerRhs>, InnerRhs> for Option<T>
where T: OptionOperations + OptionSaturatingSub<InnerRhs>, InnerRhs: Copy,

source§

type Output = <T as OptionSaturatingSub<InnerRhs>>::Output

source§

fn opt_saturating_sub(self, rhs: &Option<InnerRhs>) -> Option<Self::Output>

source§

impl<T, InnerRhs> OptionSaturatingSub<Option<InnerRhs>, InnerRhs> for Option<T>

source§

type Output = <T as OptionSaturatingSub<InnerRhs>>::Output

source§

fn opt_saturating_sub(self, rhs: Option<InnerRhs>) -> Option<Self::Output>

source§

impl<T, Rhs> OptionSaturatingSub<Rhs> for Option<T>

source§

type Output = <T as OptionSaturatingSub<Rhs>>::Output

source§

fn opt_saturating_sub(self, rhs: Rhs) -> Option<Self::Output>

Implementors§

source§

impl<T, InnerRhs> OptionSaturatingSub<&Option<InnerRhs>, InnerRhs> for T
where T: OptionOperations + OptionSaturatingSub<InnerRhs>, InnerRhs: Copy,

source§

type Output = <T as OptionSaturatingSub<InnerRhs>>::Output

source§

impl<T, InnerRhs> OptionSaturatingSub<Option<InnerRhs>, InnerRhs> for T

source§

type Output = <T as OptionSaturatingSub<InnerRhs>>::Output