Trait num::traits::CheckedMulExperimental
[-]
[+]
[src]
pub trait CheckedMul: Mul<Self, Self> { fn checked_mul(&self, v: &Self) -> Option<Self>; }
Performs multiplication that returns None
instead of wrapping around on underflow or
overflow.
Required Methods
fn checked_mul(&self, v: &Self) -> Option<Self>
Multiplies two numbers, checking for underflow or overflow. If underflow or overflow
happens, None
is returned.
Example
extern crate num; fn main() { use num::CheckedMul; assert_eq!(5u8.checked_mul(&51), Some(255)); assert_eq!(5u8.checked_mul(&52), None); }use num::CheckedMul; assert_eq!(5u8.checked_mul(&51), Some(255)); assert_eq!(5u8.checked_mul(&52), None);
Implementors
impl CheckedMul for BigUint
impl CheckedMul for BigInt
impl CheckedMul for uint
impl CheckedMul for u8
impl CheckedMul for u16
impl CheckedMul for u32
impl CheckedMul for u64
impl CheckedMul for int
impl CheckedMul for i8
impl CheckedMul for i16
impl CheckedMul for i32
impl CheckedMul for i64