summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-06-06 19:00:34 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-06-06 19:00:34 -0700
commit3b4cfdeee20eb54d43612fed461729ffa6f6d2ec (patch)
tree0b41c070f1ce581842585fa307baec946af0e244 /src/libcore
parent9c1910a66db95468608c9cc02a5012e3db7f4e09 (diff)
parentd542e67827e0ad1a3df5fd248d9c09997b5dcbba (diff)
downloadrust-3b4cfdeee20eb54d43612fed461729ffa6f6d2ec.tar.gz
rust-3b4cfdeee20eb54d43612fed461729ffa6f6d2ec.zip
Merge remote-tracking branch 'mozilla/incoming'
Conflicts:
	src/rustc/middle/tstate/auxiliary.rs
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/cmp.rs10
-rw-r--r--src/libcore/core.rc2
-rw-r--r--src/libcore/int-template.rs14
-rw-r--r--src/libcore/uint-template.rs14
4 files changed, 40 insertions, 0 deletions
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs
new file mode 100644
index 00000000000..aea97cf1649
--- /dev/null
+++ b/src/libcore/cmp.rs
@@ -0,0 +1,10 @@
+#[doc="Interfaces used for comparison."]
+
+iface ord {
+    fn lt(&&other: self) -> bool;
+}
+
+iface eq {
+    fn eq(&&other: self) -> bool;
+}
+
diff --git a/src/libcore/core.rc b/src/libcore/core.rc
index 6b4c7ad7d3c..efcd424024a 100644
--- a/src/libcore/core.rc
+++ b/src/libcore/core.rc
@@ -44,6 +44,7 @@ export extfmt;
 export tuple;
 export to_str;
 export dvec, dvec_iter;
+export cmp;
 
 // NDM seems to be necessary for resolve to work
 export option_iter;
@@ -152,6 +153,7 @@ mod tuple;
 
 // Ubiquitous-utility-type modules
 
+mod cmp;
 mod either;
 mod iter;
 mod logging;
diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs
index 156724cb061..4011ac1a18a 100644
--- a/src/libcore/int-template.rs
+++ b/src/libcore/int-template.rs
@@ -1,4 +1,5 @@
 import T = inst::T;
+import cmp::{eq, ord};
 
 export min_value, max_value;
 export min, max;
@@ -10,6 +11,7 @@ export range;
 export compl;
 export abs;
 export parse_buf, from_str, to_str, to_str_bytes, str;
+export ord, eq;
 
 const min_value: T = -1 as T << (inst::bits - 1 as T);
 const max_value: T = min_value - 1 as T;
@@ -108,6 +110,18 @@ fn to_str_bytes<U>(n: T, radix: uint, f: fn([u8]/&) -> U) -> U {
 #[doc = "Convert to a string"]
 fn str(i: T) -> str { ret to_str(i, 10u); }
 
+impl ord of ord for T {
+    fn lt(&&other: T) -> bool {
+        ret self < other;
+    }
+}
+
+impl eq of eq for T {
+    fn eq(&&other: T) -> bool {
+        ret self == other;
+    }
+}
+
 
 // FIXME: Has alignment issues on windows and 32-bit linux
 #[test]
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs
index a63d01e6e8e..7126fb3d007 100644
--- a/src/libcore/uint-template.rs
+++ b/src/libcore/uint-template.rs
@@ -1,4 +1,5 @@
 import T = inst::T;
+import cmp::{eq, ord};
 
 export min_value, max_value;
 export min, max;
@@ -10,6 +11,7 @@ export range;
 export compl;
 export to_str, to_str_bytes;
 export from_str, from_str_radix, str, parse_buf;
+export ord, eq;
 
 const min_value: T = 0 as T;
 const max_value: T = 0 as T - 1 as T;
@@ -49,6 +51,18 @@ pure fn compl(i: T) -> T {
     max_value ^ i
 }
 
+impl ord of ord for T {
+    fn lt(&&other: T) -> bool {
+        ret self < other;
+    }
+}
+
+impl eq of eq for T {
+    fn eq(&&other: T) -> bool {
+        ret self == other;
+    }
+}
+
 #[doc = "
 Parse a buffer of bytes