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

    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

The resulting inner type after applying the substraction.

Required Methods

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

Implementors