Trait option_operations::add::OptionOverflowingAdd[][src]

pub trait OptionOverflowingAdd<Rhs = Self, InnerRhs = Rhs> {
    type Output;
    fn opt_overflowing_add(self, rhs: Rhs) -> Option<(Self::Output, bool)>;
}
Expand description

Trait for values and Options overflowing addition.

Implementing this type leads to the following auto-implementations:

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

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

Associated Types

The resulting inner type after applying the operation.

Required methods

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

Returns None if at least one argument is None.

Implementations on Foreign Types

Implementors