about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-12-05 19:22:48 -0800
committerBrian Anderson <banderson@mozilla.com>2012-12-05 19:23:13 -0800
commit4ab1c8805aee4b6a4254fd90695371a06cbcd301 (patch)
treedab4555175a51694f1e5fa31d986e3a851b089a1 /src/libcore
parente23ea24aed95885c8bc59de49c616f60fa5053d1 (diff)
Convert Num to explicit self
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/f32.rs16
-rw-r--r--src/libcore/f64.rs16
-rw-r--r--src/libcore/float.rs16
-rw-r--r--src/libcore/int-template.rs16
-rw-r--r--src/libcore/num.rs14
-rw-r--r--src/libcore/uint-template.rs16
6 files changed, 47 insertions, 47 deletions
diff --git a/src/libcore/f32.rs b/src/libcore/f32.rs
index 3b4af904eee..9fbf902170a 100644
--- a/src/libcore/f32.rs
+++ b/src/libcore/f32.rs
@@ -163,14 +163,14 @@ impl f32 : cmp::Ord {
 }
 
 impl f32: num::Num {
-    pure fn add(other: &f32)    -> f32 { return self + *other; }
-    pure fn sub(other: &f32)    -> f32 { return self - *other; }
-    pure fn mul(other: &f32)    -> f32 { return self * *other; }
-    pure fn div(other: &f32)    -> f32 { return self / *other; }
-    pure fn modulo(other: &f32) -> f32 { return self % *other; }
-    pure fn neg()                -> f32 { return -self;        }
-
-    pure fn to_int()         -> int { return self as int; }
+    pure fn add(&self, other: &f32) -> f32 { return *self + *other; }
+    pure fn sub(&self, other: &f32) -> f32 { return *self - *other; }
+    pure fn mul(&self, other: &f32) -> f32 { return *self * *other; }
+    pure fn div(&self, other: &f32) -> f32 { return *self / *other; }
+    pure fn modulo(&self, other: &f32) -> f32 { return *self % *other; }
+    pure fn neg(&self)                -> f32 { return -*self;        }
+
+    pure fn to_int(&self)         -> int { return *self as int; }
     static pure fn from_int(n: int) -> f32 { return n as f32;    }
 }
 
diff --git a/src/libcore/f64.rs b/src/libcore/f64.rs
index 360da91f654..86565f9e252 100644
--- a/src/libcore/f64.rs
+++ b/src/libcore/f64.rs
@@ -182,14 +182,14 @@ impl f64 : cmp::Ord {
 }
 
 impl f64: num::Num {
-    pure fn add(other: &f64)    -> f64 { return self + *other; }
-    pure fn sub(other: &f64)    -> f64 { return self - *other; }
-    pure fn mul(other: &f64)    -> f64 { return self * *other; }
-    pure fn div(other: &f64)    -> f64 { return self / *other; }
-    pure fn modulo(other: &f64) -> f64 { return self % *other; }
-    pure fn neg()                -> f64 { return -self;        }
-
-    pure fn to_int()         -> int { return self as int; }
+    pure fn add(&self, other: &f64)    -> f64 { return *self + *other; }
+    pure fn sub(&self, other: &f64)    -> f64 { return *self - *other; }
+    pure fn mul(&self, other: &f64)    -> f64 { return *self * *other; }
+    pure fn div(&self, other: &f64)    -> f64 { return *self / *other; }
+    pure fn modulo(&self, other: &f64) -> f64 { return *self % *other; }
+    pure fn neg(&self)                -> f64 { return -*self;        }
+
+    pure fn to_int(&self)         -> int { return *self as int; }
     static pure fn from_int(n: int) -> f64 { return n as f64;    }
 }
 
diff --git a/src/libcore/float.rs b/src/libcore/float.rs
index d95b7a276b2..2a86d7ae04f 100644
--- a/src/libcore/float.rs
+++ b/src/libcore/float.rs
@@ -425,22 +425,22 @@ impl float : Ord {
 
 impl float: num::Num {
     #[inline(always)]
-    pub pure fn add(other: &float)    -> float { return self + *other; }
+    pub pure fn add(&self, other: &float) -> float { return *self + *other; }
     #[inline(always)]
-    pub pure fn sub(other: &float)    -> float { return self - *other; }
+    pub pure fn sub(&self, other: &float) -> float { return *self - *other; }
     #[inline(always)]
-    pub pure fn mul(other: &float)    -> float { return self * *other; }
+    pub pure fn mul(&self, other: &float) -> float { return *self * *other; }
     #[inline(always)]
-    pub pure fn div(other: &float)    -> float { return self / *other; }
+    pub pure fn div(&self, other: &float) -> float { return *self / *other; }
     #[inline(always)]
-    pure fn modulo(other: &float) -> float { return self % *other; }
+    pure fn modulo(&self, other: &float) -> float { return *self % *other; }
     #[inline(always)]
-    pure fn neg()                  -> float { return -self;        }
+    pure fn neg(&self)                  -> float { return -*self;        }
 
     #[inline(always)]
-    pure fn to_int()         -> int   { return self as int; }
+    pure fn to_int(&self)         -> int   { return *self as int; }
     #[inline(always)]
-    static pure fn from_int(n: int) -> float { return n as float;  }
+    static pure fn from_int(&self, n: int) -> float { return n as float;  }
 }
 
 #[test]
diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs
index 5b80745b972..dbeb51b813f 100644
--- a/src/libcore/int-template.rs
+++ b/src/libcore/int-template.rs
@@ -79,14 +79,14 @@ impl T : Eq {
 }
 
 impl T: num::Num {
-    pure fn add(other: &T)    -> T { return self + *other; }
-    pure fn sub(other: &T)    -> T { return self - *other; }
-    pure fn mul(other: &T)    -> T { return self * *other; }
-    pure fn div(other: &T)    -> T { return self / *other; }
-    pure fn modulo(other: &T) -> T { return self % *other; }
-    pure fn neg()              -> T { return -self;        }
-
-    pure fn to_int()         -> int { return self as int; }
+    pure fn add(&self, other: &T)    -> T { return *self + *other; }
+    pure fn sub(&self, other: &T)    -> T { return *self - *other; }
+    pure fn mul(&self, other: &T)    -> T { return *self * *other; }
+    pure fn div(&self, other: &T)    -> T { return *self / *other; }
+    pure fn modulo(&self, other: &T) -> T { return *self % *other; }
+    pure fn neg(&self)              -> T { return -*self;        }
+
+    pure fn to_int(&self)         -> int { return *self as int; }
     static pure fn from_int(n: int) -> T   { return n as T;      }
 }
 
diff --git a/src/libcore/num.rs b/src/libcore/num.rs
index bc36c3c2fff..fed9db8767b 100644
--- a/src/libcore/num.rs
+++ b/src/libcore/num.rs
@@ -12,13 +12,13 @@
 
 pub trait Num {
     // FIXME: Trait composition. (#2616)
-    pure fn add(other: &self) -> self;
-    pure fn sub(other: &self) -> self;
-    pure fn mul(other: &self) -> self;
-    pure fn div(other: &self) -> self;
-    pure fn modulo(other: &self) -> self;
-    pure fn neg() -> self;
+    pure fn add(&self, other: &self) -> self;
+    pure fn sub(&self, other: &self) -> self;
+    pure fn mul(&self, other: &self) -> self;
+    pure fn div(&self, other: &self) -> self;
+    pure fn modulo(&self, other: &self) -> self;
+    pure fn neg(&self) -> self;
 
-    pure fn to_int() -> int;
+    pure fn to_int(&self) -> int;
     static pure fn from_int(n: int) -> self;
 }
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs
index 17f76619583..8a03b0f94bc 100644
--- a/src/libcore/uint-template.rs
+++ b/src/libcore/uint-template.rs
@@ -73,14 +73,14 @@ impl T : Eq {
 }
 
 impl T: num::Num {
-    pure fn add(other: &T)    -> T { return self + *other; }
-    pure fn sub(other: &T)    -> T { return self - *other; }
-    pure fn mul(other: &T)    -> T { return self * *other; }
-    pure fn div(other: &T)    -> T { return self / *other; }
-    pure fn modulo(other: &T) -> T { return self % *other; }
-    pure fn neg()              -> T { return -self;        }
-
-    pure fn to_int()         -> int { return self as int; }
+    pure fn add(&self, other: &T)    -> T { return *self + *other; }
+    pure fn sub(&self, other: &T)    -> T { return *self - *other; }
+    pure fn mul(&self, other: &T)    -> T { return *self * *other; }
+    pure fn div(&self, other: &T)    -> T { return *self / *other; }
+    pure fn modulo(&self, other: &T) -> T { return *self % *other; }
+    pure fn neg(&self)              -> T { return -*self;        }
+
+    pure fn to_int(&self)         -> int { return *self as int; }
     static pure fn from_int(n: int) -> T   { return n as T;      }
 }