Skip to main content

OptionAdd

Trait OptionAdd 

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

    // Required method
    fn opt_add(self, rhs: Rhs) -> Option<Self::Output>;
}
Expand description

Trait for values and Options addition.

Implementing this trait leads to the following auto-implementations:

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

This trait is auto-implemented for OptionOperations types implementing Add<Rhs>.

Required Associated Types§

Source

type Output

The resulting inner type after applying the addition.

Required Methods§

Source

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

Computes the addition.

Returns None if at least one argument is None.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

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

Source§

type Output = <T as OptionAdd<InnerRhs>>::Output

Source§

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

Source§

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

Source§

type Output = <T as OptionAdd<InnerRhs>>::Output

Source§

fn opt_add( self, rhs: Option<InnerRhs>, ) -> Option<<Option<T> as OptionAdd<Option<InnerRhs>, InnerRhs>>::Output>

Source§

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

Source§

type Output = <T as OptionAdd<Rhs>>::Output

Source§

fn opt_add(self, rhs: Rhs) -> Option<<Option<T> as OptionAdd<Rhs>>::Output>

Implementors§

Source§

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

Source§

type Output = <T as OptionAdd<InnerRhs>>::Output

Source§

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

Source§

type Output = <T as OptionAdd<InnerRhs>>::Output

Source§

impl<T, Rhs> OptionAdd<Rhs> for T
where T: OptionOperations + Add<Rhs>,

Source§

type Output = <T as Add<Rhs>>::Output