Added impls of `Checked…` for `i128` and `u128`
This commit is contained in:
parent
bc19c34934
commit
b44666183d
|
@ -24,12 +24,16 @@ checked_impl!(CheckedAdd, checked_add, u16);
|
|||
checked_impl!(CheckedAdd, checked_add, u32);
|
||||
checked_impl!(CheckedAdd, checked_add, u64);
|
||||
checked_impl!(CheckedAdd, checked_add, usize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_impl!(CheckedAdd, checked_add, u128);
|
||||
|
||||
checked_impl!(CheckedAdd, checked_add, i8);
|
||||
checked_impl!(CheckedAdd, checked_add, i16);
|
||||
checked_impl!(CheckedAdd, checked_add, i32);
|
||||
checked_impl!(CheckedAdd, checked_add, i64);
|
||||
checked_impl!(CheckedAdd, checked_add, isize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_impl!(CheckedAdd, checked_add, i128);
|
||||
|
||||
/// Performs subtraction that returns `None` instead of wrapping around on underflow.
|
||||
pub trait CheckedSub: Sized + Sub<Self, Output=Self> {
|
||||
|
@ -43,12 +47,16 @@ checked_impl!(CheckedSub, checked_sub, u16);
|
|||
checked_impl!(CheckedSub, checked_sub, u32);
|
||||
checked_impl!(CheckedSub, checked_sub, u64);
|
||||
checked_impl!(CheckedSub, checked_sub, usize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_impl!(CheckedSub, checked_sub, u128);
|
||||
|
||||
checked_impl!(CheckedSub, checked_sub, i8);
|
||||
checked_impl!(CheckedSub, checked_sub, i16);
|
||||
checked_impl!(CheckedSub, checked_sub, i32);
|
||||
checked_impl!(CheckedSub, checked_sub, i64);
|
||||
checked_impl!(CheckedSub, checked_sub, isize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_impl!(CheckedSub, checked_sub, i128);
|
||||
|
||||
/// Performs multiplication that returns `None` instead of wrapping around on underflow or
|
||||
/// overflow.
|
||||
|
@ -63,12 +71,16 @@ checked_impl!(CheckedMul, checked_mul, u16);
|
|||
checked_impl!(CheckedMul, checked_mul, u32);
|
||||
checked_impl!(CheckedMul, checked_mul, u64);
|
||||
checked_impl!(CheckedMul, checked_mul, usize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_impl!(CheckedMul, checked_mul, u128);
|
||||
|
||||
checked_impl!(CheckedMul, checked_mul, i8);
|
||||
checked_impl!(CheckedMul, checked_mul, i16);
|
||||
checked_impl!(CheckedMul, checked_mul, i32);
|
||||
checked_impl!(CheckedMul, checked_mul, i64);
|
||||
checked_impl!(CheckedMul, checked_mul, isize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_impl!(CheckedMul, checked_mul, i128);
|
||||
|
||||
/// Performs division that returns `None` instead of panicking on division by zero and instead of
|
||||
/// wrapping around on underflow and overflow.
|
||||
|
@ -83,12 +95,16 @@ checked_impl!(CheckedDiv, checked_div, u16);
|
|||
checked_impl!(CheckedDiv, checked_div, u32);
|
||||
checked_impl!(CheckedDiv, checked_div, u64);
|
||||
checked_impl!(CheckedDiv, checked_div, usize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_impl!(CheckedDiv, checked_div, u128);
|
||||
|
||||
checked_impl!(CheckedDiv, checked_div, i8);
|
||||
checked_impl!(CheckedDiv, checked_div, i16);
|
||||
checked_impl!(CheckedDiv, checked_div, i32);
|
||||
checked_impl!(CheckedDiv, checked_div, i64);
|
||||
checked_impl!(CheckedDiv, checked_div, isize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_impl!(CheckedDiv, checked_div, i128);
|
||||
|
||||
/// Performs a left shift that returns `None` on overflow.
|
||||
pub trait CheckedShl: Sized + Shl<u32, Output=Self> {
|
||||
|
@ -124,12 +140,16 @@ checked_shift_impl!(CheckedShl, checked_shl, u16);
|
|||
checked_shift_impl!(CheckedShl, checked_shl, u32);
|
||||
checked_shift_impl!(CheckedShl, checked_shl, u64);
|
||||
checked_shift_impl!(CheckedShl, checked_shl, usize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_shift_impl!(CheckedShl, checked_shl, u128);
|
||||
|
||||
checked_shift_impl!(CheckedShl, checked_shl, i8);
|
||||
checked_shift_impl!(CheckedShl, checked_shl, i16);
|
||||
checked_shift_impl!(CheckedShl, checked_shl, i32);
|
||||
checked_shift_impl!(CheckedShl, checked_shl, i64);
|
||||
checked_shift_impl!(CheckedShl, checked_shl, isize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_shift_impl!(CheckedShl, checked_shl, i128);
|
||||
|
||||
/// Performs a right shift that returns `None` on overflow.
|
||||
pub trait CheckedShr: Sized + Shr<u32, Output=Self> {
|
||||
|
@ -154,9 +174,13 @@ checked_shift_impl!(CheckedShr, checked_shr, u16);
|
|||
checked_shift_impl!(CheckedShr, checked_shr, u32);
|
||||
checked_shift_impl!(CheckedShr, checked_shr, u64);
|
||||
checked_shift_impl!(CheckedShr, checked_shr, usize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_shift_impl!(CheckedShr, checked_shr, u128);
|
||||
|
||||
checked_shift_impl!(CheckedShr, checked_shr, i8);
|
||||
checked_shift_impl!(CheckedShr, checked_shr, i16);
|
||||
checked_shift_impl!(CheckedShr, checked_shr, i32);
|
||||
checked_shift_impl!(CheckedShr, checked_shr, i64);
|
||||
checked_shift_impl!(CheckedShr, checked_shr, isize);
|
||||
#[cfg(feature = "i128")]
|
||||
checked_shift_impl!(CheckedShr, checked_shr, i128);
|
||||
|
|
Loading…
Reference in New Issue