Trait option_operations::mul::OptionCheckedMul

source ·
pub trait OptionCheckedMul<Rhs = Self, InnerRhs = Rhs> {
    type Output;

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

Trait for values and Options checked multiplication.

Implementing this trait leads to the following auto-implementations:

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

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

Required Associated Types§

source

type Output

The resulting inner type after applying the multiplication.

Required Methods§

source

fn opt_checked_mul(self, rhs: Rhs) -> Result<Option<Self::Output>, Error>

Computes the checked multiplication.

  • Returns Ok(Some(result)) if result could be computed.
  • Returns Ok(None) if at least one argument is None.
  • Returns Err(Error::Overflow) if an overflow occured.

Implementations on Foreign Types§

source§

impl OptionCheckedMul for i8

source§

type Output = i8

source§

fn opt_checked_mul(self, rhs: Self) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedMul for i16

source§

type Output = i16

source§

fn opt_checked_mul(self, rhs: Self) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedMul for i32

source§

type Output = i32

source§

fn opt_checked_mul(self, rhs: Self) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedMul for i64

source§

type Output = i64

source§

fn opt_checked_mul(self, rhs: Self) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedMul for i128

source§

type Output = i128

source§

fn opt_checked_mul(self, rhs: Self) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedMul for u8

source§

type Output = u8

source§

fn opt_checked_mul(self, rhs: Self) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedMul for u16

source§

type Output = u16

source§

fn opt_checked_mul(self, rhs: Self) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedMul for u32

source§

type Output = u32

source§

fn opt_checked_mul(self, rhs: Self) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedMul for u64

source§

type Output = u64

source§

fn opt_checked_mul(self, rhs: Self) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedMul for u128

source§

type Output = u128

source§

fn opt_checked_mul(self, rhs: Self) -> Result<Option<Self::Output>, Error>

source§

impl OptionCheckedMul<u32> for Duration

source§

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

source§

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

source§

fn opt_checked_mul( self, rhs: &Option<InnerRhs>, ) -> Result<Option<Self::Output>, Error>

source§

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

source§

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

source§

fn opt_checked_mul( self, rhs: Option<InnerRhs>, ) -> Result<Option<Self::Output>, Error>

source§

impl<T, Rhs> OptionCheckedMul<Rhs> for Option<T>

source§

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

source§

fn opt_checked_mul(self, rhs: Rhs) -> Result<Option<Self::Output>, Error>

Implementors§

source§

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

source§

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

source§

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

source§

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