diff options
| author | bors <bors@rust-lang.org> | 2014-05-28 12:41:40 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-05-28 12:41:40 -0700 |
| commit | e865415c2fe2c0e83fe1955238db082a1374c380 (patch) | |
| tree | 0e0ab6993ac13addc61cef0e3c8ffd0b5a09725a /src/libcore/num/uint.rs | |
| parent | 98c2b4b4ac7a110aee7c236f5d5c392dc7617a03 (diff) | |
| parent | dd0d495f50e2d8ba501e6b003cb4c1ef52d95ed5 (diff) | |
auto merge of #14464 : Sawyer47/rust/issue-12925, r=alexcrichton
This is an attempt of fixing #12925. This PR moves almost all trait implementations for primitive types ((), bool, char, i*, u*, f*) near trait definitions. Only Float trait implementations weren't moved because they heavily rely on constants defined in f32.rs and f64.rs. Some trait implementations had cfg(not(test)) attribute. I suspect it's because of issue 2912. Still, someone who knows the problem better should probably check this code. Closes #12925
Diffstat (limited to 'src/libcore/num/uint.rs')
| -rw-r--r-- | src/libcore/num/uint.rs | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/src/libcore/num/uint.rs b/src/libcore/num/uint.rs index f988650cc01..99ed7e10bf9 100644 --- a/src/libcore/num/uint.rs +++ b/src/libcore/num/uint.rs @@ -10,83 +10,5 @@ //! Operations and constants for architecture-sized unsigned integers (`uint` type) -use default::Default; -use intrinsics; -use num::{Bitwise, Bounded, Zero, One, Unsigned, Num, Int, Primitive}; -use num::{CheckedAdd, CheckedSub, CheckedMul, CheckedDiv}; -use option::{Some, None, Option}; - -#[cfg(not(test))] -use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering}; -#[cfg(not(test))] -use ops::{Add, Sub, Mul, Div, Rem, Neg, BitAnd, BitOr, BitXor}; -#[cfg(not(test))] -use ops::{Shl, Shr, Not}; - uint_module!(uint, int, ::int::BITS) -#[cfg(target_word_size = "32")] -impl CheckedAdd for uint { - #[inline] - fn checked_add(&self, v: &uint) -> Option<uint> { - unsafe { - let (x, y) = intrinsics::u32_add_with_overflow(*self as u32, *v as u32); - if y { None } else { Some(x as uint) } - } - } -} - -#[cfg(target_word_size = "64")] -impl CheckedAdd for uint { - #[inline] - fn checked_add(&self, v: &uint) -> Option<uint> { - unsafe { - let (x, y) = intrinsics::u64_add_with_overflow(*self as u64, *v as u64); - if y { None } else { Some(x as uint) } - } - } -} - -#[cfg(target_word_size = "32")] -impl CheckedSub for uint { - #[inline] - fn checked_sub(&self, v: &uint) -> Option<uint> { - unsafe { - let (x, y) = intrinsics::u32_sub_with_overflow(*self as u32, *v as u32); - if y { None } else { Some(x as uint) } - } - } -} - -#[cfg(target_word_size = "64")] -impl CheckedSub for uint { - #[inline] - fn checked_sub(&self, v: &uint) -> Option<uint> { - unsafe { - let (x, y) = intrinsics::u64_sub_with_overflow(*self as u64, *v as u64); - if y { None } else { Some(x as uint) } - } - } -} - -#[cfg(target_word_size = "32")] -impl CheckedMul for uint { - #[inline] - fn checked_mul(&self, v: &uint) -> Option<uint> { - unsafe { - let (x, y) = intrinsics::u32_mul_with_overflow(*self as u32, *v as u32); - if y { None } else { Some(x as uint) } - } - } -} - -#[cfg(target_word_size = "64")] -impl CheckedMul for uint { - #[inline] - fn checked_mul(&self, v: &uint) -> Option<uint> { - unsafe { - let (x, y) = intrinsics::u64_mul_with_overflow(*self as u64, *v as u64); - if y { None } else { Some(x as uint) } - } - } -} |
