about summary refs log tree commit diff
path: root/src/libstd/num/uint_macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/num/uint_macros.rs')
-rw-r--r--src/libstd/num/uint_macros.rs206
1 files changed, 2 insertions, 204 deletions
diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs
index fac8736b929..3e64c171613 100644
--- a/src/libstd/num/uint_macros.rs
+++ b/src/libstd/num/uint_macros.rs
@@ -12,140 +12,7 @@
 #![doc(hidden)]
 #![allow(unsigned_negate)]
 
-macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (
-
-pub static BITS : uint = $bits;
-pub static BYTES : uint = ($bits / 8);
-
-pub static MIN: $T = 0 as $T;
-pub static MAX: $T = 0 as $T - 1 as $T;
-
-impl CheckedDiv for $T {
-    #[inline]
-    fn checked_div(&self, v: &$T) -> Option<$T> {
-        if *v == 0 {
-            None
-        } else {
-            Some(self / *v)
-        }
-    }
-}
-
-impl Num for $T {}
-
-#[cfg(not(test))]
-impl Ord for $T {
-    #[inline]
-    fn lt(&self, other: &$T) -> bool { (*self) < (*other) }
-}
-
-#[cfg(not(test))]
-impl Eq for $T {
-    #[inline]
-    fn eq(&self, other: &$T) -> bool { return (*self) == (*other); }
-}
-
-impl Default for $T {
-    #[inline]
-    fn default() -> $T { 0 }
-}
-
-impl Zero for $T {
-    #[inline]
-    fn zero() -> $T { 0 }
-
-    #[inline]
-    fn is_zero(&self) -> bool { *self == 0 }
-}
-
-impl One for $T {
-    #[inline]
-    fn one() -> $T { 1 }
-}
-
-#[cfg(not(test))]
-impl Add<$T,$T> for $T {
-    #[inline]
-    fn add(&self, other: &$T) -> $T { *self + *other }
-}
-
-#[cfg(not(test))]
-impl Sub<$T,$T> for $T {
-    #[inline]
-    fn sub(&self, other: &$T) -> $T { *self - *other }
-}
-
-#[cfg(not(test))]
-impl Mul<$T,$T> for $T {
-    #[inline]
-    fn mul(&self, other: &$T) -> $T { *self * *other }
-}
-
-#[cfg(not(test))]
-impl Div<$T,$T> for $T {
-    #[inline]
-    fn div(&self, other: &$T) -> $T { *self / *other }
-}
-
-#[cfg(not(test))]
-impl Rem<$T,$T> for $T {
-    #[inline]
-    fn rem(&self, other: &$T) -> $T { *self % *other }
-}
-
-#[cfg(not(test))]
-impl Neg<$T> for $T {
-    #[inline]
-    fn neg(&self) -> $T { -*self }
-}
-
-impl Unsigned for $T {}
-
-#[cfg(not(test))]
-impl BitOr<$T,$T> for $T {
-    #[inline]
-    fn bitor(&self, other: &$T) -> $T { *self | *other }
-}
-
-#[cfg(not(test))]
-impl BitAnd<$T,$T> for $T {
-    #[inline]
-    fn bitand(&self, other: &$T) -> $T { *self & *other }
-}
-
-#[cfg(not(test))]
-impl BitXor<$T,$T> for $T {
-    #[inline]
-    fn bitxor(&self, other: &$T) -> $T { *self ^ *other }
-}
-
-#[cfg(not(test))]
-impl Shl<$T,$T> for $T {
-    #[inline]
-    fn shl(&self, other: &$T) -> $T { *self << *other }
-}
-
-#[cfg(not(test))]
-impl Shr<$T,$T> for $T {
-    #[inline]
-    fn shr(&self, other: &$T) -> $T { *self >> *other }
-}
-
-#[cfg(not(test))]
-impl Not<$T> for $T {
-    #[inline]
-    fn not(&self) -> $T { !*self }
-}
-
-impl Bounded for $T {
-    #[inline]
-    fn min_value() -> $T { MIN }
-
-    #[inline]
-    fn max_value() -> $T { MAX }
-}
-
-impl Int for $T {}
+macro_rules! uint_module (($T:ty) => (
 
 // String conversion functions and impl str -> num
 
@@ -211,7 +78,7 @@ impl ToStrRadix for $T {
     /// Convert to a string in a given base.
     #[inline]
     fn to_str_radix(&self, radix: uint) -> ~str {
-        let mut buf = Vec::new();
+        let mut buf = ::vec::Vec::new();
         strconv::int_to_str_bytes_common(*self, radix, strconv::SignNone, |i| {
             buf.push(i);
         });
@@ -221,79 +88,16 @@ impl ToStrRadix for $T {
     }
 }
 
-impl Primitive for $T {}
-
-impl Bitwise for $T {
-    /// Returns the number of ones in the binary representation of the number.
-    #[inline]
-    fn count_ones(&self) -> $T {
-        (*self as $T_SIGNED).count_ones() as $T
-    }
-
-    /// Returns the number of leading zeros in the in the binary representation
-    /// of the number.
-    #[inline]
-    fn leading_zeros(&self) -> $T {
-        (*self as $T_SIGNED).leading_zeros() as $T
-    }
-
-    /// Returns the number of trailing zeros in the in the binary representation
-    /// of the number.
-    #[inline]
-    fn trailing_zeros(&self) -> $T {
-        (*self as $T_SIGNED).trailing_zeros() as $T
-    }
-}
-
 #[cfg(test)]
 mod tests {
     use prelude::*;
     use super::*;
 
-    use num;
-    use num::CheckedDiv;
-    use num::Bitwise;
     use num::ToStrRadix;
     use str::StrSlice;
     use u16;
 
     #[test]
-    fn test_overflows() {
-        assert!(MAX > 0);
-        assert!(MIN <= 0);
-        assert_eq!(MIN + MAX + 1, 0);
-    }
-
-    #[test]
-    fn test_num() {
-        num::test_num(10 as $T, 2 as $T);
-    }
-
-    #[test]
-    fn test_bitwise() {
-        assert_eq!(0b1110 as $T, (0b1100 as $T).bitor(&(0b1010 as $T)));
-        assert_eq!(0b1000 as $T, (0b1100 as $T).bitand(&(0b1010 as $T)));
-        assert_eq!(0b0110 as $T, (0b1100 as $T).bitxor(&(0b1010 as $T)));
-        assert_eq!(0b1110 as $T, (0b0111 as $T).shl(&(1 as $T)));
-        assert_eq!(0b0111 as $T, (0b1110 as $T).shr(&(1 as $T)));
-        assert_eq!(MAX - (0b1011 as $T), (0b1011 as $T).not());
-    }
-
-    #[test]
-    fn test_count_ones() {
-        assert_eq!((0b0101100 as $T).count_ones(), 3);
-        assert_eq!((0b0100001 as $T).count_ones(), 2);
-        assert_eq!((0b1111001 as $T).count_ones(), 5);
-    }
-
-    #[test]
-    fn test_count_zeros() {
-        assert_eq!((0b0101100 as $T).count_zeros(), BITS as $T - 3);
-        assert_eq!((0b0100001 as $T).count_zeros(), BITS as $T - 2);
-        assert_eq!((0b1111001 as $T).count_zeros(), BITS as $T - 5);
-    }
-
-    #[test]
     pub fn test_to_str() {
         assert_eq!((0 as $T).to_str_radix(10u), "0".to_owned());
         assert_eq!((1 as $T).to_str_radix(10u), "1".to_owned());
@@ -404,12 +208,6 @@ mod tests {
     pub fn to_str_radix37() {
         100u.to_str_radix(37u);
     }
-
-    #[test]
-    fn test_unsigned_checked_div() {
-        assert_eq!(10u.checked_div(&2), Some(5));
-        assert_eq!(5u.checked_div(&0), None);
-    }
 }
 
 ))