about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-06-25 13:41:13 -0700
committerBrian Anderson <banderson@mozilla.com>2012-06-25 14:25:48 -0700
commit7e6cbf7431671ecdfe60f7ec9fdd5af65248a7a2 (patch)
tree970ecf66dd2a057824ef8db83532c37fbba66894 /src
parent43a48ca5bba2698e253d6229139328d353276ee8 (diff)
Remove redundant 'extension' mods from numeric mods
Diffstat (limited to 'src')
-rw-r--r--src/libcore/core.rs26
-rw-r--r--src/libcore/f32.rs28
-rw-r--r--src/libcore/f64.rs30
-rw-r--r--src/libcore/float.rs41
-rw-r--r--src/libcore/int-template.rs25
-rw-r--r--src/libcore/uint-template.rs25
-rw-r--r--src/test/run-pass/numeric-method-autoexport.rs8
7 files changed, 92 insertions, 91 deletions
diff --git a/src/libcore/core.rs b/src/libcore/core.rs
index 35c416d34e0..ed61c587116 100644
--- a/src/libcore/core.rs
+++ b/src/libcore/core.rs
@@ -12,19 +12,19 @@ import option_iter::extensions;
 import ptr::extensions;
 import rand::extensions;
 import result::extensions;
-import int::extensions::*;
-import i8::extensions::*;
-import i16::extensions::*;
-import i32::extensions::*;
-import i64::extensions::*;
-import uint::extensions::*;
-import u8::extensions::*;
-import u16::extensions::*;
-import u32::extensions::*;
-import u64::extensions::*;
-import float::extensions::*;
-import f32::extensions::*;
-import f64::extensions::*;
+import int::num;
+import i8::num;
+import i16::num;
+import i32::num;
+import i64::num;
+import uint::num;
+import u8::num;
+import u16::num;
+import u32::num;
+import u64::num;
+import float::num;
+import f32::num;
+import f64::num;
 
 export path, option, some, none, unreachable;
 export extensions;
diff --git a/src/libcore/f32.rs b/src/libcore/f32.rs
index b68771348ec..d84438f4845 100644
--- a/src/libcore/f32.rs
+++ b/src/libcore/f32.rs
@@ -4,9 +4,8 @@
 
 import cmath::c_float::*;
 import cmath::c_float_targ_consts::*;
-import num::num;
 
-export add, sub, mul, div, rem, lt, le, gt, eq, eq, ne;
+export add, sub, mul, div, rem, lt, le, gt, eq, ne;
 export is_positive, is_negative, is_nonpositive, is_nonnegative;
 export is_zero, is_infinite, is_finite;
 export NaN, is_NaN, infinity, neg_infinity;
@@ -18,7 +17,8 @@ export mul_add, fmax, fmin, nextafter, frexp, hypot, ldexp;
 export lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix;
 export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
 export signbit;
-export extensions;
+
+export num;
 
 // These are not defined inside consts:: for consistency with
 // the integer types
@@ -173,18 +173,16 @@ pure fn log2(n: f32) -> f32 {
     ret ln(n) / consts::ln_2;
 }
 
-mod extensions {
-    impl num of num for f32 {
-        fn add(&&other: f32)    -> f32 { ret self + other; }
-        fn sub(&&other: f32)    -> f32 { ret self - other; }
-        fn mul(&&other: f32)    -> f32 { ret self * other; }
-        fn div(&&other: f32)    -> f32 { ret self / other; }
-        fn modulo(&&other: f32) -> f32 { ret self % other; }
-        fn neg()                -> f32 { ret -self;        }
-
-        fn to_int()         -> int { ret self as int; }
-        fn from_int(n: int) -> f32 { ret n as f32;    }
-    }
+impl num of num::num for f32 {
+    fn add(&&other: f32)    -> f32 { ret self + other; }
+    fn sub(&&other: f32)    -> f32 { ret self - other; }
+    fn mul(&&other: f32)    -> f32 { ret self * other; }
+    fn div(&&other: f32)    -> f32 { ret self / other; }
+    fn modulo(&&other: f32) -> f32 { ret self % other; }
+    fn neg()                -> f32 { ret -self;        }
+
+    fn to_int()         -> int { ret self as int; }
+    fn from_int(n: int) -> f32 { ret n as f32;    }
 }
 
 //
diff --git a/src/libcore/f64.rs b/src/libcore/f64.rs
index 6c3a2e9bd7e..72f1b6b866a 100644
--- a/src/libcore/f64.rs
+++ b/src/libcore/f64.rs
@@ -4,12 +4,11 @@
 
 import cmath::c_double::*;
 import cmath::c_double_targ_consts::*;
-import num::num;
 
 // Even though this module exports everything defined in it,
 // because it contains re-exports, we also have to explicitly
 // export locally defined things. That's a bit annoying.
-export add, sub, mul, div, rem, lt, le, gt, eq, eq, ne;
+export add, sub, mul, div, rem, lt, le, gt, eq, ne;
 export is_positive, is_negative, is_nonpositive, is_nonnegative;
 export is_zero, is_infinite, is_finite;
 export NaN, is_NaN, infinity, neg_infinity;
@@ -22,7 +21,10 @@ export lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix;
 export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
 export signbit;
 export epsilon;
-export extensions;
+
+export j0, j1, jn, y0, y1, yn;
+
+export num;
 
 // These are not defined inside consts:: for consistency with
 // the integer types
@@ -196,18 +198,16 @@ pure fn log2(n: f64) -> f64 {
     ret ln(n) / consts::ln_2;
 }
 
-mod extensions {
-    impl num of num for f64 {
-        fn add(&&other: f64)    -> f64 { ret self + other; }
-        fn sub(&&other: f64)    -> f64 { ret self - other; }
-        fn mul(&&other: f64)    -> f64 { ret self * other; }
-        fn div(&&other: f64)    -> f64 { ret self / other; }
-        fn modulo(&&other: f64) -> f64 { ret self % other; }
-        fn neg()                -> f64 { ret -self;        }
-
-        fn to_int()         -> int { ret self as int; }
-        fn from_int(n: int) -> f64 { ret n as f64;    }
-    }
+impl num of num::num for f64 {
+    fn add(&&other: f64)    -> f64 { ret self + other; }
+    fn sub(&&other: f64)    -> f64 { ret self - other; }
+    fn mul(&&other: f64)    -> f64 { ret self * other; }
+    fn div(&&other: f64)    -> f64 { ret self / other; }
+    fn modulo(&&other: f64) -> f64 { ret self % other; }
+    fn neg()                -> f64 { ret -self;        }
+
+    fn to_int()         -> int { ret self as int; }
+    fn from_int(n: int) -> f64 { ret n as f64;    }
 }
 
 //
diff --git a/src/libcore/float.rs b/src/libcore/float.rs
index 6f63a84f053..cd6e830ab4f 100644
--- a/src/libcore/float.rs
+++ b/src/libcore/float.rs
@@ -4,7 +4,7 @@
 // because it contains re-exports, we also have to explicitly
 // export locally defined things. That's a bit annoying.
 export to_str_common, to_str_exact, to_str, from_str;
-export add, sub, mul, div, rem, lt, le, gt, eq, eq, ne;
+export add, sub, mul, div, rem, lt, le, gt, eq, ne;
 export is_positive, is_negative, is_nonpositive, is_nonnegative;
 export is_zero, is_infinite, is_finite;
 export NaN, is_NaN, infinity, neg_infinity;
@@ -17,7 +17,8 @@ export lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix;
 export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
 export signbit;
 export pow_with_uint;
-export extensions;
+
+export num;
 
 // export when m_float == c_double
 
@@ -26,8 +27,16 @@ export j0, j1, jn, y0, y1, yn;
 // PORT this must match in width according to architecture
 
 import m_float = f64;
-import f64::*;
-import num::num;
+
+import f64::{add, sub, mul, div, rem, lt, le, gt, eq, ne};
+import f64::logarithm;
+import f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};
+import f64::{erf, erfc, exp, expm1, exp2, abs_sub};
+import f64::{mul_add, fmax, fmin, nextafter, frexp, hypot, ldexp};
+import f64::{lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix};
+import f64::{modf, pow, round, sinh, tanh, tgamma, trunc};
+import f64::signbit;
+import f64::{j0, j1, jn, y0, y1, yn};
 
 const NaN: float = 0.0/0.0;
 
@@ -410,18 +419,16 @@ fn sin(x: float) -> float { f64::sin(x as f64) as float }
 fn cos(x: float) -> float { f64::cos(x as f64) as float }
 fn tan(x: float) -> float { f64::tan(x as f64) as float }
 
-mod extensions {
-    impl num of num for float {
-        fn add(&&other: float)    -> float { ret self + other; }
-        fn sub(&&other: float)    -> float { ret self - other; }
-        fn mul(&&other: float)    -> float { ret self * other; }
-        fn div(&&other: float)    -> float { ret self / other; }
-        fn modulo(&&other: float) -> float { ret self % other; }
-        fn neg()                  -> float { ret -self;        }
-
-        fn to_int()         -> int   { ret self as int; }
-        fn from_int(n: int) -> float { ret n as float;  }
-    }
+impl num of num::num for float {
+    fn add(&&other: float)    -> float { ret self + other; }
+    fn sub(&&other: float)    -> float { ret self - other; }
+    fn mul(&&other: float)    -> float { ret self * other; }
+    fn div(&&other: float)    -> float { ret self / other; }
+    fn modulo(&&other: float) -> float { ret self % other; }
+    fn neg()                  -> float { ret -self;        }
+
+    fn to_int()         -> int   { ret self as int; }
+    fn from_int(n: int) -> float { ret n as float;  }
 }
 
 #[test]
@@ -519,7 +526,7 @@ fn test_to_str_inf() {
 
 #[test]
 fn test_ifaces() {
-    fn test<U:num>(ten: U) {
+    fn test<U:num::num>(ten: U) {
         assert (ten.to_int() == 10);
 
         let two = ten.from_int(2);
diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs
index 7b751416f17..7f3d385dca0 100644
--- a/src/libcore/int-template.rs
+++ b/src/libcore/int-template.rs
@@ -1,6 +1,5 @@
 import T = inst::T;
 import cmp::{eq, ord};
-import num::num;
 
 export min_value, max_value;
 export min, max;
@@ -12,7 +11,7 @@ export range;
 export compl;
 export abs;
 export parse_buf, from_str, to_str, to_str_bytes, str;
-export ord, eq, extensions;
+export num, ord, eq;
 
 const min_value: T = -1 as T << (inst::bits - 1 as T);
 const max_value: T = min_value - 1 as T;
@@ -124,18 +123,16 @@ impl eq of eq for T {
     }
 }
 
-mod extensions {
-    impl num of num::num for T {
-        fn add(&&other: T)    -> T { ret self + other; }
-        fn sub(&&other: T)    -> T { ret self - other; }
-        fn mul(&&other: T)    -> T { ret self * other; }
-        fn div(&&other: T)    -> T { ret self / other; }
-        fn modulo(&&other: T) -> T { ret self % other; }
-        fn neg()              -> T { ret -self;        }
-
-        fn to_int()         -> int { ret self as int; }
-        fn from_int(n: int) -> T   { ret n as T;      }
-    }
+impl num of num::num for T {
+    fn add(&&other: T)    -> T { ret self + other; }
+    fn sub(&&other: T)    -> T { ret self - other; }
+    fn mul(&&other: T)    -> T { ret self * other; }
+    fn div(&&other: T)    -> T { ret self / other; }
+    fn modulo(&&other: T) -> T { ret self % other; }
+    fn neg()              -> T { ret -self;        }
+
+    fn to_int()         -> int { ret self as int; }
+    fn from_int(n: int) -> T   { ret n as T;      }
 }
 
 
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs
index 5d8c9415a77..d341921eb03 100644
--- a/src/libcore/uint-template.rs
+++ b/src/libcore/uint-template.rs
@@ -1,6 +1,5 @@
 import T = inst::T;
 import cmp::{eq, ord};
-import num::num;
 
 export min_value, max_value;
 export min, max;
@@ -12,7 +11,7 @@ export range;
 export compl;
 export to_str, to_str_bytes;
 export from_str, from_str_radix, str, parse_buf;
-export ord, eq, extensions;
+export num, ord, eq;
 
 const min_value: T = 0 as T;
 const max_value: T = 0 as T - 1 as T;
@@ -65,18 +64,16 @@ impl eq of eq for T {
     }
 }
 
-mod extensions {
-    impl num of num::num for T {
-        fn add(&&other: T)    -> T { ret self + other; }
-        fn sub(&&other: T)    -> T { ret self - other; }
-        fn mul(&&other: T)    -> T { ret self * other; }
-        fn div(&&other: T)    -> T { ret self / other; }
-        fn modulo(&&other: T) -> T { ret self % other; }
-        fn neg()              -> T { ret -self;        }
-
-        fn to_int()         -> int { ret self as int; }
-        fn from_int(n: int) -> T   { ret n as T;      }
-    }
+impl num of num::num for T {
+    fn add(&&other: T)    -> T { ret self + other; }
+    fn sub(&&other: T)    -> T { ret self - other; }
+    fn mul(&&other: T)    -> T { ret self * other; }
+    fn div(&&other: T)    -> T { ret self / other; }
+    fn modulo(&&other: T) -> T { ret self % other; }
+    fn neg()              -> T { ret -self;        }
+
+    fn to_int()         -> int { ret self as int; }
+    fn from_int(n: int) -> T   { ret n as T;      }
 }
 
 #[doc = "
diff --git a/src/test/run-pass/numeric-method-autoexport.rs b/src/test/run-pass/numeric-method-autoexport.rs
index c00444cfc66..6a7bd93b929 100644
--- a/src/test/run-pass/numeric-method-autoexport.rs
+++ b/src/test/run-pass/numeric-method-autoexport.rs
@@ -1,23 +1,25 @@
+
+
 // This file is intended to test only that methods are automatically
 // reachable for each numeric type, for each exported impl, with no imports
 // necessary. Testing the methods of the impls is done within the source
 // file for each numeric type.
 fn main() {
-    // extensions::num
+    // num
     assert 15.add(6) == 21;
     assert 15i8.add(6i8) == 21i8;
     assert 15i16.add(6i16) == 21i16;
     assert 15i32.add(6i32) == 21i32;
     assert 15i64.add(6i64) == 21i64;
 
-    // extensions::num
+    // num
     assert 15u.add(6u) == 21u;
     assert 15u8.add(6u8) == 21u8;
     assert 15u16.add(6u16) == 21u16;
     assert 15u32.add(6u32) == 21u32;
     assert 15u64.add(6u64) == 21u64;
 
-    // extensions::num
+    // num
     assert 10f.to_int() == 10;
     assert 10f32.to_int() == 10;
     assert 10f64.to_int() == 10;