about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-06-07 18:27:10 -0700
committerPatrick Walton <pcwalton@mimiga.net>2012-06-07 18:27:10 -0700
commite158ce8a9d49767cddf58c3e656d382e16aa232e (patch)
treed3b227cf16dc13235c2793dbec74de0a99314d66 /src
parentd8b113f209006e595e13c1baa1557c1fbedad46d (diff)
downloadrust-e158ce8a9d49767cddf58c3e656d382e16aa232e.tar.gz
rust-e158ce8a9d49767cddf58c3e656d382e16aa232e.zip
Add neg() to the num iface
Diffstat (limited to 'src')
-rw-r--r--src/libcore/f32.rs1
-rw-r--r--src/libcore/f64.rs1
-rw-r--r--src/libcore/float.rs1
-rw-r--r--src/libcore/int-template.rs1
-rw-r--r--src/libcore/num.rs1
-rw-r--r--src/libcore/uint-template.rs1
6 files changed, 6 insertions, 0 deletions
diff --git a/src/libcore/f32.rs b/src/libcore/f32.rs
index 89a8bfa424f..e1d30081966 100644
--- a/src/libcore/f32.rs
+++ b/src/libcore/f32.rs
@@ -184,6 +184,7 @@ impl num of num for f32 {
     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 151b90d4fcb..af83a0829e1 100644
--- a/src/libcore/f64.rs
+++ b/src/libcore/f64.rs
@@ -205,6 +205,7 @@ impl num of num for f64 {
     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 a2b5197277a..d55c0e0c371 100644
--- a/src/libcore/float.rs
+++ b/src/libcore/float.rs
@@ -416,6 +416,7 @@ impl num of num for float {
     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;  }
diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs
index 8d9225b05a8..556b9944dde 100644
--- a/src/libcore/int-template.rs
+++ b/src/libcore/int-template.rs
@@ -129,6 +129,7 @@ impl num of num for T {
     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/num.rs b/src/libcore/num.rs
index 7d57f7ff55b..eb5073c14b8 100644
--- a/src/libcore/num.rs
+++ b/src/libcore/num.rs
@@ -8,6 +8,7 @@ iface num {
     fn mul(&&other: self) -> self;
     fn div(&&other: self) -> self;
     fn modulo(&&other: self) -> self;
+    fn neg() -> self;
 
     fn to_int() -> int;
     fn from_int(n: int) -> self;    // TODO: Static functions.
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs
index 9d658605f5a..d1d238d298c 100644
--- a/src/libcore/uint-template.rs
+++ b/src/libcore/uint-template.rs
@@ -70,6 +70,7 @@ impl num of num for T {
     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;      }