Trait option_operations::sub::OptionCheckedSub

source ·
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§

source

type Output

The resulting inner type after applying the substraction.

Required Methods§

source

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§

source§

impl OptionCheckedSub for i8

source§

type Output = i8

source§

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

source§

impl OptionCheckedSub for i16

source§

type Output = i16

source§

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

source§

impl OptionCheckedSub for i32

source§

type Output = i32

source§

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

source§

impl OptionCheckedSub for i64

source§

type Output = i64

source§

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

source§

impl OptionCheckedSub for i128

source§

type Output = i128

source§

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

source§

impl OptionCheckedSub for u8

source§

type Output = u8

source§

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

source§

impl OptionCheckedSub for u16

source§

type Output = u16

source§

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

source§

impl OptionCheckedSub for u32

source§

type Output = u32

source§

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

source§

impl OptionCheckedSub for u64

source§

type Output = u64

source§

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

source§

impl OptionCheckedSub for u128

source§

type Output = u128

source§

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

source§

impl OptionCheckedSub for Duration

source§

impl OptionCheckedSub<Duration> for Instant

source§

impl OptionCheckedSub<Duration> for SystemTime

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

Implementors§

source§

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

source§

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

source§

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

source§

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