about summary refs log tree commit diff
path: root/src/libstd/num/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/num/mod.rs')
-rw-r--r--src/libstd/num/mod.rs21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs
index 05f21c7d448..ab2604ee196 100644
--- a/src/libstd/num/mod.rs
+++ b/src/libstd/num/mod.rs
@@ -17,6 +17,7 @@
 
 use clone::{Clone, DeepClone};
 use cmp::{Eq, Ord};
+use mem::size_of;
 use ops::{Add, Sub, Mul, Div, Rem, Neg};
 use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr};
 use option::{Option, Some, None};
@@ -381,19 +382,7 @@ pub trait Primitive: Clone
                    + Num
                    + NumCast
                    + Orderable
-                   + Bounded
-                   + Neg<Self>
-                   + Add<Self,Self>
-                   + Sub<Self,Self>
-                   + Mul<Self,Self>
-                   + Div<Self,Self>
-                   + Rem<Self,Self> {
-    // FIXME (#5527): These should be associated constants
-    // FIXME (#8888): Removing `unused_self` requires #8888 to be fixed.
-    fn bits(unused_self: Option<Self>) -> uint;
-    fn bytes(unused_self: Option<Self>) -> uint;
-    fn is_signed(unused_self: Option<Self>) -> bool;
-}
+                   + Bounded {}
 
 /// A collection of traits relevant to primitive signed and unsigned integers
 pub trait Int: Integer
@@ -536,7 +525,7 @@ pub trait ToPrimitive {
 macro_rules! impl_to_primitive_int_to_int(
     ($SrcT:ty, $DstT:ty) => (
         {
-            if Primitive::bits(None::<$SrcT>) <= Primitive::bits(None::<$DstT>) {
+            if size_of::<$SrcT>() <= size_of::<$DstT>() {
                 Some(*self as $DstT)
             } else {
                 let n = *self as i64;
@@ -621,7 +610,7 @@ macro_rules! impl_to_primitive_uint_to_int(
 macro_rules! impl_to_primitive_uint_to_uint(
     ($SrcT:ty, $DstT:ty) => (
         {
-            if Primitive::bits(None::<$SrcT>) <= Primitive::bits(None::<$DstT>) {
+            if size_of::<$SrcT>() <= size_of::<$DstT>() {
                 Some(*self as $DstT)
             } else {
                 let zero: $SrcT = Zero::zero();
@@ -677,7 +666,7 @@ impl_to_primitive_uint!(u64)
 
 macro_rules! impl_to_primitive_float_to_float(
     ($SrcT:ty, $DstT:ty) => (
-        if Primitive::bits(None::<$SrcT>) <= Primitive::bits(None::<$DstT>) {
+        if size_of::<$SrcT>() <= size_of::<$DstT>() {
             Some(*self as $DstT)
         } else {
             let n = *self as f64;