CheckedMul
Performs multiplication that returns None
instead of wrapping around on underflow or overflow. # Examples
use core::num::traits::CheckedMul;
let result = 10_u8.checked_mul(20);
assert!(result == Option::Some(200));
let result = 10_u8.checked_mul(30);
assert!(result == Option::None); // Overflow
Fully qualified path: core::num::traits::ops::checked::CheckedMul
pub trait CheckedMul<T>
Trait functions
checked_mul
Multiplies two numbers, checking for underflow or overflow. If underflow or overflow happens, None
is returned.
Fully qualified path: core::num::traits::ops::checked::CheckedMul::checked_mul
fn checked_mul(self: T, v: T) -> Option<T>