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

Trait for values and Options wrapping addition.

Implementing this trait leads to the following auto-implementations:

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

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

Associated Types

The resulting inner type after applying the addition.

Required methods

Computes the addition wrapping at the numeric bounds instead of overflowing.

Returns None if at least one argument is None.

Implementations on Foreign Types

Implementors