Trait option_operations::div::OptionCheckedDiv[][src]

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

Trait for values and Options checked division.

Implementing this type leads to the following auto-implementations:

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

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

Associated Types

The resulting inner type after applying the operation.

Required methods

Computes the checked division.

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

Implementations on Foreign Types

Implementors