pub trait ArithmeticTryOps<RHS = Self>{
// Required methods
fn try_add(self, other: RHS) -> Result<Self, OverflowError<Self, RHS>>;
fn try_sub(self, other: RHS) -> Result<Self, OverflowError<Self, RHS>>;
fn try_mul(self, other: RHS) -> Result<Self, OverflowError<Self, RHS>>;
fn try_div(self, other: RHS) -> Result<Self, DivisionByZeroError<Self>>;
fn try_div_euclid(
self,
other: RHS,
) -> Result<Self, DivisionByZeroError<Self>>;
fn try_rem(self, other: RHS) -> Result<Self, DivisionByZeroError<Self>>;
fn try_rem_euclid(
self,
other: RHS,
) -> Result<Self, DivisionByZeroError<Self>>;
fn try_pow(self, other: u32) -> Result<Self, OverflowError<Self, u32>>;
fn try_shl(self, other: u32) -> Result<Self, BigShiftError<Self>>;
fn try_shr(self, other: u32) -> Result<Self, BigShiftError<Self>>;
}
Expand description
Adds arithmetic operations similar to checked_*
but returning Result with nice errors
Required Methods§
fn try_add(self, other: RHS) -> Result<Self, OverflowError<Self, RHS>>
fn try_sub(self, other: RHS) -> Result<Self, OverflowError<Self, RHS>>
fn try_mul(self, other: RHS) -> Result<Self, OverflowError<Self, RHS>>
fn try_div(self, other: RHS) -> Result<Self, DivisionByZeroError<Self>>
fn try_div_euclid(self, other: RHS) -> Result<Self, DivisionByZeroError<Self>>
fn try_rem(self, other: RHS) -> Result<Self, DivisionByZeroError<Self>>
fn try_rem_euclid(self, other: RHS) -> Result<Self, DivisionByZeroError<Self>>
fn try_pow(self, other: u32) -> Result<Self, OverflowError<Self, u32>>
fn try_shl(self, other: u32) -> Result<Self, BigShiftError<Self>>
fn try_shr(self, other: u32) -> Result<Self, BigShiftError<Self>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.