Update checked.rs

This commit is contained in:
LEXUGE 2018-04-05 19:21:51 +08:00 committed by GitHub
parent ca343c0af2
commit 9047722838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 28 deletions

View File

@ -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,