about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorblake2-ppc <blake2-ppc>2013-07-15 04:00:39 +0200
committerblake2-ppc <blake2-ppc>2013-07-15 13:24:35 +0200
commit6999b5332f845292c4fdab824ae0fe2e3bf53421 (patch)
tree9ec59b01dac605fa0efe967a7f59d681373d6804 /src/libstd
parent68a32aad1ab60b29ebfffd7c2f8d5967371955fc (diff)
downloadrust-6999b5332f845292c4fdab824ae0fe2e3bf53421.tar.gz
rust-6999b5332f845292c4fdab824ae0fe2e3bf53421.zip
cmp: Use default methods in trait Eq, require only Eq::eq
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/cmp.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs
index 77d4e945aae..8a13cab28c3 100644
--- a/src/libstd/cmp.rs
+++ b/src/libstd/cmp.rs
@@ -21,6 +21,7 @@ and `Eq` to overload the `==` and `!=` operators.
 */
 
 #[allow(missing_doc)];
+#[allow(default_methods)]; // NOTE: Remove when allowed in stage0
 
 /**
 * Trait for values that can be compared for equality and inequality.
@@ -29,12 +30,14 @@ and `Eq` to overload the `==` and `!=` operators.
 * unequal. For example, with the built-in floating-point types `a == b` and `a != b` will both
 * evaluate to false if either `a` or `b` is NaN (cf. IEEE 754-2008 section 5.11).
 *
+* Eq only requires the `eq` method to be implemented; `ne` is its negation by default.
+*
 * Eventually, this will be implemented by default for types that implement `TotalEq`.
 */
 #[lang="eq"]
 pub trait Eq {
     fn eq(&self, other: &Self) -> bool;
-    fn ne(&self, other: &Self) -> bool;
+    fn ne(&self, other: &Self) -> bool { !self.eq(other) }
 }
 
 /// Trait for equality comparisons where `a == b` and `a != b` are strict inverses.
@@ -164,7 +167,6 @@ pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering {
 * for compatibility with floating-point NaN semantics
 * (cf. IEEE 754-2008 section 5.11).
 */
-#[allow(default_methods)] // NOTE: Remove when allowed in stage0
 #[lang="ord"]
 pub trait Ord {
     fn lt(&self, other: &Self) -> bool;