pub trait CheckedMul: Mul + Sized {
// Required method
fn checked_mul(self, rhs: Self) -> Option<Self>;
}
Expand description
Performs checked multiplication. Maps directly to the integers checked_mul method. (i.e.
u8::checked_mul
) Consult the docs of the primitive methods to learn more.
Required Methods§
Sourcefn checked_mul(self, rhs: Self) -> Option<Self>
fn checked_mul(self, rhs: Self) -> Option<Self>
performs checked mul
§Example
let a = 2u8;
let b = 1u8;
assert_eq!(CheckedMul::checked_mul(a, b), a.checked_mul(b));
assert_eq!(CheckedMul::checked_mul(a, u8::MAX), a.checked_mul(u8::MAX));
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.