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

    // Required method
    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.

Required Associated Types§

source

type Output

The resulting inner type after applying the addition.

Required Methods§

source

fn opt_wrapping_add(self, rhs: Rhs) -> Option<Self::Output>

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

Returns None if at least one argument is None.

Implementations on Foreign Types§

source§

impl OptionWrappingAdd<i128, i128> for i128

source§

impl OptionWrappingAdd<u32, u32> for u32

source§

impl OptionWrappingAdd<u8, u8> for u8

source§

impl OptionWrappingAdd<u128, u128> for u128

source§

impl<T, InnerRhs> OptionWrappingAdd<Option<InnerRhs>, InnerRhs> for Option<T>where T: OptionOperations + OptionWrappingAdd<InnerRhs, InnerRhs>,

§

type Output = <T as OptionWrappingAdd<InnerRhs, InnerRhs>>::Output

source§

fn opt_wrapping_add( self, rhs: Option<InnerRhs> ) -> Option<<Option<T> as OptionWrappingAdd<Option<InnerRhs>, InnerRhs>>::Output>

source§

impl OptionWrappingAdd<i8, i8> for i8

source§

impl<T, InnerRhs> OptionWrappingAdd<&Option<InnerRhs>, InnerRhs> for Option<T>where T: OptionOperations + OptionWrappingAdd<InnerRhs, InnerRhs>, InnerRhs: Copy,

§

type Output = <T as OptionWrappingAdd<InnerRhs, InnerRhs>>::Output

source§

fn opt_wrapping_add( self, rhs: &Option<InnerRhs> ) -> Option<<Option<T> as OptionWrappingAdd<&Option<InnerRhs>, InnerRhs>>::Output>

source§

impl OptionWrappingAdd<u64, u64> for u64

source§

impl<T, Rhs> OptionWrappingAdd<Rhs, Rhs> for Option<T>where T: OptionOperations + OptionWrappingAdd<Rhs, Rhs>,

§

type Output = <T as OptionWrappingAdd<Rhs, Rhs>>::Output

source§

fn opt_wrapping_add( self, rhs: Rhs ) -> Option<<Option<T> as OptionWrappingAdd<Rhs, Rhs>>::Output>

source§

impl OptionWrappingAdd<i16, i16> for i16

source§

impl OptionWrappingAdd<u16, u16> for u16

source§

impl OptionWrappingAdd<i64, i64> for i64

source§

impl OptionWrappingAdd<i32, i32> for i32

Implementors§

source§

impl OptionWrappingAdd<Buffers, Buffers> for Buffers

source§

impl OptionWrappingAdd<Bytes, Bytes> for Bytes

source§

impl OptionWrappingAdd<ClockTime, ClockTime> for ClockTime

source§

impl OptionWrappingAdd<Default, Default> for Default

source§

impl OptionWrappingAdd<Other, Other> for Other

source§

impl OptionWrappingAdd<Percent, Percent> for Percent

source§

impl<T, InnerRhs> OptionWrappingAdd<&Option<InnerRhs>, InnerRhs> for Twhere T: OptionOperations + OptionWrappingAdd<InnerRhs, InnerRhs>, InnerRhs: Copy,

§

type Output = <T as OptionWrappingAdd<InnerRhs, InnerRhs>>::Output

source§

impl<T, InnerRhs> OptionWrappingAdd<Option<InnerRhs>, InnerRhs> for Twhere T: OptionOperations + OptionWrappingAdd<InnerRhs, InnerRhs>,

§

type Output = <T as OptionWrappingAdd<InnerRhs, InnerRhs>>::Output