about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-11-28 11:28:13 -0800
committerBrian Anderson <banderson@mozilla.com>2012-11-29 18:10:11 -0800
commit28ecef7bf5c25439a565a000fe9acad1463a05c7 (patch)
tree6335a3ed399c1c93c2fb1ced33d6d7172db4b1f4 /src
parent05e7ba8d397274a3ab7f621b0a1e84ca27f0c219 (diff)
core: Add impls of Eq and Ord for f32, f64
Diffstat (limited to 'src')
-rw-r--r--src/libcore/f32.rs12
-rw-r--r--src/libcore/f64.rs12
2 files changed, 24 insertions, 0 deletions
diff --git a/src/libcore/f32.rs b/src/libcore/f32.rs
index ed6908d110d..7ddf81629eb 100644
--- a/src/libcore/f32.rs
+++ b/src/libcore/f32.rs
@@ -138,6 +138,18 @@ pub pure fn logarithm(n: f32, b: f32) -> f32 {
     return log2(n) / log2(b);
 }
 
+impl f32 : cmp::Eq {
+    pure fn eq(&self, other: &f32) -> bool { (*self) == (*other) }
+    pure fn ne(&self, other: &f32) -> bool { (*self) != (*other) }
+}
+
+impl f32 : cmp::Ord {
+    pure fn lt(&self, other: &f32) -> bool { (*self) < (*other) }
+    pure fn le(&self, other: &f32) -> bool { (*self) <= (*other) }
+    pure fn ge(&self, other: &f32) -> bool { (*self) >= (*other) }
+    pure fn gt(&self, other: &f32) -> bool { (*self) > (*other) }
+}
+
 impl f32: num::Num {
     pure fn add(other: &f32)    -> f32 { return self + *other; }
     pure fn sub(other: &f32)    -> f32 { return self - *other; }
diff --git a/src/libcore/f64.rs b/src/libcore/f64.rs
index 2d13dc86e2f..c2d99d1ed40 100644
--- a/src/libcore/f64.rs
+++ b/src/libcore/f64.rs
@@ -157,6 +157,18 @@ pub pure fn logarithm(n: f64, b: f64) -> f64 {
     return log2(n) / log2(b);
 }
 
+impl f64 : cmp::Eq {
+    pure fn eq(&self, other: &f64) -> bool { (*self) == (*other) }
+    pure fn ne(&self, other: &f64) -> bool { (*self) != (*other) }
+}
+
+impl f64 : cmp::Ord {
+    pure fn lt(&self, other: &f64) -> bool { (*self) < (*other) }
+    pure fn le(&self, other: &f64) -> bool { (*self) <= (*other) }
+    pure fn ge(&self, other: &f64) -> bool { (*self) >= (*other) }
+    pure fn gt(&self, other: &f64) -> bool { (*self) > (*other) }
+}
+
 impl f64: num::Num {
     pure fn add(other: &f64)    -> f64 { return self + *other; }
     pure fn sub(other: &f64)    -> f64 { return self - *other; }