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

    fn opt_saturating_add(self, rhs: Rhs) -> Option<Self::Output>;
Expand description

Trait for values and Options saturating addition.

Implementing this trait leads to the following auto-implementations:

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

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

Required Associated Types§

The resulting inner type after applying the addition.

Required Methods§

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

Returns None if at least one argument is None.

Implementations on Foreign Types§