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

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

Trait for values and Options checked substraction.

Implementing this trait leads to the following auto-implementations:

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

Note that since the std library doesn’t define any CheckedSub 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_checked_sub(self, rhs: Rhs) -> Result<Option<Self::Output>, Error>

Computes the checked substraction.

  • Returns Ok(Some(result)) if result could be computed.
  • Returns Ok(None) if at least one argument is None.
  • Returns Err(Error::Overflow) if an overflow occured.

Implementations on Foreign Types§

§

impl OptionCheckedSub for i8

§

type Output = i8

§

fn opt_checked_sub( self, rhs: i8 ) -> Result<Option<<i8 as OptionCheckedSub>::Output>, Error>

§

impl OptionCheckedSub for i16

§

type Output = i16

§

fn opt_checked_sub( self, rhs: i16 ) -> Result<Option<<i16 as OptionCheckedSub>::Output>, Error>

§

impl OptionCheckedSub for i32

§

type Output = i32

§

fn opt_checked_sub( self, rhs: i32 ) -> Result<Option<<i32 as OptionCheckedSub>::Output>, Error>

§

impl OptionCheckedSub for i64

§

type Output = i64

§

fn opt_checked_sub( self, rhs: i64 ) -> Result<Option<<i64 as OptionCheckedSub>::Output>, Error>

§

impl OptionCheckedSub for i128

§

type Output = i128

§

fn opt_checked_sub( self, rhs: i128 ) -> Result<Option<<i128 as OptionCheckedSub>::Output>, Error>

§

impl OptionCheckedSub for u8

§

type Output = u8

§

fn opt_checked_sub( self, rhs: u8 ) -> Result<Option<<u8 as OptionCheckedSub>::Output>, Error>

§

impl OptionCheckedSub for u16

§

type Output = u16

§

fn opt_checked_sub( self, rhs: u16 ) -> Result<Option<<u16 as OptionCheckedSub>::Output>, Error>

§

impl OptionCheckedSub for u32

§

type Output = u32

§

fn opt_checked_sub( self, rhs: u32 ) -> Result<Option<<u32 as OptionCheckedSub>::Output>, Error>

§

impl OptionCheckedSub for u64

§

type Output = u64

§

fn opt_checked_sub( self, rhs: u64 ) -> Result<Option<<u64 as OptionCheckedSub>::Output>, Error>

§

impl OptionCheckedSub for u128

§

type Output = u128

§

fn opt_checked_sub( self, rhs: u128 ) -> Result<Option<<u128 as OptionCheckedSub>::Output>, Error>

§

impl OptionCheckedSub for Duration

source§

impl OptionCheckedSub<Signed<u32>> for u32

§

type Output = Signed<u32>

source§

fn opt_checked_sub( self, rhs: Signed<u32> ) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedSub<Signed<u64>> for u64

§

type Output = Signed<u64>

source§

fn opt_checked_sub( self, rhs: Signed<u64> ) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedSub<Signed<usize>> for usize

§

type Output = Signed<usize>

source§

fn opt_checked_sub( self, rhs: Signed<usize> ) -> Result<Option<Self::Output>, Error>

§

impl OptionCheckedSub<Duration> for Instant

§

impl OptionCheckedSub<Duration> for SystemTime

§

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

§

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

§

fn opt_checked_sub( self, rhs: &Option<InnerRhs> ) -> Result<Option<<Option<T> as OptionCheckedSub<&Option<InnerRhs>, InnerRhs>>::Output>, Error>

§

impl<T, InnerRhs> OptionCheckedSub<Option<InnerRhs>, InnerRhs> for Option<T>
where T: OptionOperations + OptionCheckedSub<InnerRhs>,

§

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

§

fn opt_checked_sub( self, rhs: Option<InnerRhs> ) -> Result<Option<<Option<T> as OptionCheckedSub<Option<InnerRhs>, InnerRhs>>::Output>, Error>

§

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

§

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

§

fn opt_checked_sub( self, rhs: Rhs ) -> Result<Option<<Option<T> as OptionCheckedSub<Rhs>>::Output>, Error>

Implementors§

source§

impl OptionCheckedSub for Signed<u32>

source§

impl OptionCheckedSub for Signed<u64>

source§

impl OptionCheckedSub for Signed<usize>

source§

impl OptionCheckedSub for Signed<Buffers>

source§

impl OptionCheckedSub for Signed<Bytes>

source§

impl OptionCheckedSub for Signed<ClockTime>

source§

impl OptionCheckedSub for Signed<Default>

source§

impl OptionCheckedSub for Signed<Other>

source§

impl OptionCheckedSub for Signed<Percent>

source§

impl OptionCheckedSub for Buffers

source§

impl OptionCheckedSub for Bytes

source§

impl OptionCheckedSub for ClockTime

source§

impl OptionCheckedSub for Default

source§

impl OptionCheckedSub for Other

source§

impl OptionCheckedSub for Percent

source§

impl OptionCheckedSub<Signed<Buffers>> for Buffers

source§

impl OptionCheckedSub<Signed<Bytes>> for Bytes

source§

impl OptionCheckedSub<Signed<ClockTime>> for ClockTime

source§

impl OptionCheckedSub<Signed<Default>> for Default

source§

impl OptionCheckedSub<Signed<Other>> for Other

source§

impl OptionCheckedSub<Signed<Percent>> for Percent

source§

impl OptionCheckedSub<u32> for Signed<u32>

source§

impl OptionCheckedSub<u64> for Signed<u64>

source§

impl OptionCheckedSub<usize> for Signed<usize>

source§

impl OptionCheckedSub<Buffers> for Signed<Buffers>

source§

impl OptionCheckedSub<Bytes> for Signed<Bytes>

source§

impl OptionCheckedSub<ClockTime> for Signed<ClockTime>

source§

impl OptionCheckedSub<Default> for Signed<Default>

source§

impl OptionCheckedSub<Other> for Signed<Other>

source§

impl OptionCheckedSub<Percent> for Signed<Percent>

§

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

§

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

§

impl<T, InnerRhs> OptionCheckedSub<Option<InnerRhs>, InnerRhs> for T
where T: OptionOperations + OptionCheckedSub<InnerRhs>,

§

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