pub trait OptionOverflowingSub<Rhs = Self, InnerRhs = Rhs> {
    type Output;

    // Required method
    fn opt_overflowing_sub(self, rhs: Rhs) -> Option<(Self::Output, bool)>;
}
Expand description

Trait for values and Options overflowing substraction.

Implementing this trait leads to the following auto-implementations:

  • OptionOverflowingSub<Option<InnerRhs>> for T.
  • OptionOverflowingSub<Rhs> for Option<T>.
  • OptionOverflowingSub<Option<InnerRhs>> for Option<T>.
  • … and some variants with references.

Note that since the std library doesn’t define any OverflowingSub trait, users must provide the base implementation for the inner type.

Required Associated Types§

type Output

The resulting inner type after applying the substraction.

Required Methods§

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

Returns a tuple of the substraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then self is returned.

Returns None if at least one argument is None.

Implementations on Foreign Types§

§

impl OptionOverflowingSub for i8

§

impl OptionOverflowingSub for i16

§

impl OptionOverflowingSub for i32

§

impl OptionOverflowingSub for i64

§

impl OptionOverflowingSub for i128

§

impl OptionOverflowingSub for u8

§

impl OptionOverflowingSub for u16

§

impl OptionOverflowingSub for u32

§

impl OptionOverflowingSub for u64

§

impl OptionOverflowingSub for u128

§

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

§

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

§

fn opt_overflowing_sub( self, rhs: &Option<InnerRhs> ) -> Option<(<Option<T> as OptionOverflowingSub<&Option<InnerRhs>, InnerRhs>>::Output, bool)>

§

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

§

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

§

fn opt_overflowing_sub( self, rhs: Option<InnerRhs> ) -> Option<(<Option<T> as OptionOverflowingSub<Option<InnerRhs>, InnerRhs>>::Output, bool)>

§

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

§

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

§

fn opt_overflowing_sub( self, rhs: Rhs ) -> Option<(<Option<T> as OptionOverflowingSub<Rhs>>::Output, bool)>

Implementors§