pub trait OptionOverflowingSub<Rhs = Self, InnerRhs = Rhs> {
    type Output;
    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.

Associated Types

The resulting inner type after applying the substraction.

Required methods

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

Implementors