Update checked.rs
This commit is contained in:
parent
ca343c0af2
commit
9047722838
|
@ -107,34 +107,6 @@ checked_impl!(CheckedRem, checked_rem, i32);
|
|||
checked_impl!(CheckedRem, checked_rem, i64);
|
||||
checked_impl!(CheckedRem, checked_rem, isize);
|
||||
|
||||
macro_rules! checked_abs_impl {
|
||||
($t:ty) => {
|
||||
impl CheckedAbs for $t {
|
||||
#[inline]
|
||||
fn checked_abs(self) -> Option<$t> {
|
||||
<$t>::checked_abs(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CheckedAbs
|
||||
pub trait CheckedAbs: Sized {
|
||||
fn checked_abs(self) -> Option<i32>;
|
||||
}
|
||||
|
||||
checked_abs_impl!(u8);
|
||||
checked_abs_impl!(u16);
|
||||
checked_abs_impl!(u32);
|
||||
checked_abs_impl!(u64);
|
||||
checked_abs_impl!(usize);
|
||||
|
||||
checked_abs_impl!(i8);
|
||||
checked_abs_impl!(i16);
|
||||
checked_abs_impl!(i32);
|
||||
checked_abs_impl!(i64);
|
||||
checked_abs_impl!(isize);
|
||||
|
||||
/// Performs a left shift that returns `None` on overflow.
|
||||
pub trait CheckedShl: Sized + Shl<u32, Output=Self> {
|
||||
/// Shifts a number to the left, checking for overflow. If overflow happens,
|
||||
|
|
Loading…
Reference in New Issue