about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-05-31 10:43:52 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-06-01 10:31:27 -0700
commitbba701c59d84eac4e20d0796ec06db8d1cdd39cf (patch)
tree3c2109ca567bbc7e7b8d66da7282dac8f8926da6 /src/libcore
parentc605c2b57b412402e6b491e91852fd9dbadeb551 (diff)
downloadrust-bba701c59d84eac4e20d0796ec06db8d1cdd39cf.tar.gz
rust-bba701c59d84eac4e20d0796ec06db8d1cdd39cf.zip
std: Drop Total from Total{Eq,Ord}
This completes the last stage of the renaming of the comparison hierarchy of
traits. This change renames TotalEq to Eq and TotalOrd to Ord.

In the future the new Eq/Ord will be filled out with their appropriate methods,
but for now this change is purely a renaming change.

[breaking-change]
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/cmp.rs41
-rw-r--r--src/libcore/intrinsics.rs2
-rw-r--r--src/libcore/iter.rs18
-rw-r--r--src/libcore/option.rs4
-rw-r--r--src/libcore/prelude.rs4
-rw-r--r--src/libcore/ptr.rs6
-rw-r--r--src/libcore/result.rs2
-rw-r--r--src/libcore/slice.rs18
-rw-r--r--src/libcore/str.rs10
-rw-r--r--src/libcore/tuple.rs10
10 files changed, 56 insertions, 59 deletions
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs
index 80bc4f31a13..ef00643177b 100644
--- a/src/libcore/cmp.rs
+++ b/src/libcore/cmp.rs
@@ -37,9 +37,6 @@
 //! assert!(SketchyNum {num: 25} != SketchyNum {num: 57});
 //! ```
 
-pub use Eq = self::TotalEq;
-pub use Ord = self::TotalOrd;
-
 /// Trait for values that can be compared for equality and inequality.
 ///
 /// This trait allows partial equality, where types can be unordered instead of
@@ -51,7 +48,7 @@ pub use Ord = self::TotalOrd;
 /// default.
 ///
 /// Eventually, this will be implemented by default for types that implement
-/// `TotalEq`.
+/// `Eq`.
 #[lang="eq"]
 pub trait PartialEq {
     /// This method tests for `self` and `other` values to be equal, and is used by `==`.
@@ -71,7 +68,7 @@ pub trait PartialEq {
 /// - reflexive: `a == a`;
 /// - symmetric: `a == b` implies `b == a`; and
 /// - transitive: `a == b` and `b == c` implies `a == c`.
-pub trait TotalEq: PartialEq {
+pub trait Eq: PartialEq {
     // FIXME #13101: this method is used solely by #[deriving] to
     // assert that every component of a type implements #[deriving]
     // itself, the current deriving infrastructure means doing this
@@ -104,7 +101,7 @@ pub enum Ordering {
 ///   true; and
 /// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for
 ///   both `==` and `>`.
-pub trait TotalOrd: TotalEq + PartialOrd {
+pub trait Ord: Eq + PartialOrd {
     /// This method returns an ordering between `self` and `other` values.
     ///
     /// By convention, `self.cmp(&other)` returns the ordering matching
@@ -118,9 +115,9 @@ pub trait TotalOrd: TotalEq + PartialOrd {
     fn cmp(&self, other: &Self) -> Ordering;
 }
 
-impl TotalEq for Ordering {}
+impl Eq for Ordering {}
 
-impl TotalOrd for Ordering {
+impl Ord for Ordering {
     #[inline]
     fn cmp(&self, other: &Ordering) -> Ordering {
         (*self as int).cmp(&(*other as int))
@@ -182,20 +179,20 @@ pub trait Equiv<T> {
 
 /// Compare and return the minimum of two values.
 #[inline]
-pub fn min<T: TotalOrd>(v1: T, v2: T) -> T {
+pub fn min<T: Ord>(v1: T, v2: T) -> T {
     if v1 < v2 { v1 } else { v2 }
 }
 
 /// Compare and return the maximum of two values.
 #[inline]
-pub fn max<T: TotalOrd>(v1: T, v2: T) -> T {
+pub fn max<T: Ord>(v1: T, v2: T) -> T {
     if v1 > v2 { v1 } else { v2 }
 }
 
-// Implementation of PartialEq, TotalEq, PartialOrd and TotalOrd for primitive types
+// Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types
 #[cfg(not(test))]
 mod impls {
-    use cmp::{PartialOrd, TotalOrd, PartialEq, TotalEq, Ordering,
+    use cmp::{PartialOrd, Ord, PartialEq, Eq, Ordering,
               Less, Greater, Equal};
 
     macro_rules! eq_impl(
@@ -220,7 +217,7 @@ mod impls {
 
     macro_rules! totaleq_impl(
         ($($t:ty)*) => ($(
-            impl TotalEq for $t {}
+            impl Eq for $t {}
         )*)
     )
 
@@ -257,7 +254,7 @@ mod impls {
 
     macro_rules! totalord_impl(
         ($($t:ty)*) => ($(
-            impl TotalOrd for $t {
+            impl Ord for $t {
                 #[inline]
                 fn cmp(&self, other: &$t) -> Ordering {
                     if *self < *other { Less }
@@ -268,12 +265,12 @@ mod impls {
         )*)
     )
 
-    impl TotalOrd for () {
+    impl Ord for () {
         #[inline]
         fn cmp(&self, _other: &()) -> Ordering { Equal }
     }
 
-    impl TotalOrd for bool {
+    impl Ord for bool {
         #[inline]
         fn cmp(&self, other: &bool) -> Ordering {
             (*self as u8).cmp(&(*other as u8))
@@ -299,11 +296,11 @@ mod impls {
         #[inline]
         fn gt(&self, other: & &'a T) -> bool { *(*self) > *(*other) }
     }
-    impl<'a, T: TotalOrd> TotalOrd for &'a T {
+    impl<'a, T: Ord> Ord for &'a T {
         #[inline]
         fn cmp(&self, other: & &'a T) -> Ordering { (**self).cmp(*other) }
     }
-    impl<'a, T: TotalEq> TotalEq for &'a T {}
+    impl<'a, T: Eq> Eq for &'a T {}
 
     // &mut pointers
     impl<'a, T: PartialEq> PartialEq for &'a mut T {
@@ -322,11 +319,11 @@ mod impls {
         #[inline]
         fn gt(&self, other: &&'a mut T) -> bool { **self > **other }
     }
-    impl<'a, T: TotalOrd> TotalOrd for &'a mut T {
+    impl<'a, T: Ord> Ord for &'a mut T {
         #[inline]
         fn cmp(&self, other: &&'a mut T) -> Ordering { (**self).cmp(*other) }
     }
-    impl<'a, T: TotalEq> TotalEq for &'a mut T {}
+    impl<'a, T: Eq> Eq for &'a mut T {}
 
     // @ pointers
     impl<T:PartialEq> PartialEq for @T {
@@ -345,11 +342,11 @@ mod impls {
         #[inline]
         fn gt(&self, other: &@T) -> bool { *(*self) > *(*other) }
     }
-    impl<T: TotalOrd> TotalOrd for @T {
+    impl<T: Ord> Ord for @T {
         #[inline]
         fn cmp(&self, other: &@T) -> Ordering { (**self).cmp(*other) }
     }
-    impl<T: TotalEq> TotalEq for @T {}
+    impl<T: Eq> Eq for @T {}
 }
 
 #[cfg(test)]
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs
index b36735713af..35c8afee4b6 100644
--- a/src/libcore/intrinsics.rs
+++ b/src/libcore/intrinsics.rs
@@ -550,7 +550,7 @@ extern "rust-intrinsic" {
 /// `TypeId` represents a globally unique identifier for a type
 #[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and
                   // middle/lang_items.rs
-#[deriving(PartialEq, TotalEq, Show)]
+#[deriving(PartialEq, Eq, Show)]
 #[cfg(not(test))]
 pub struct TypeId {
     t: u64,
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index 4438b6ec980..875c852d8ae 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -68,7 +68,7 @@ use cmp;
 use num::{Zero, One, CheckedAdd, CheckedSub, Saturating, ToPrimitive, Int};
 use option::{Option, Some, None};
 use ops::{Add, Mul, Sub};
-use cmp::{PartialEq, PartialOrd, TotalOrd};
+use cmp::{PartialEq, PartialOrd, Ord};
 use clone::Clone;
 use uint;
 use mem;
@@ -611,7 +611,7 @@ pub trait Iterator<A> {
     /// assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10);
     /// ```
     #[inline]
-    fn max_by<B: TotalOrd>(&mut self, f: |&A| -> B) -> Option<A> {
+    fn max_by<B: Ord>(&mut self, f: |&A| -> B) -> Option<A> {
         self.fold(None, |max: Option<(A, B)>, x| {
             let x_val = f(&x);
             match max {
@@ -635,7 +635,7 @@ pub trait Iterator<A> {
     /// assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0);
     /// ```
     #[inline]
-    fn min_by<B: TotalOrd>(&mut self, f: |&A| -> B) -> Option<A> {
+    fn min_by<B: Ord>(&mut self, f: |&A| -> B) -> Option<A> {
         self.fold(None, |min: Option<(A, B)>, x| {
             let x_val = f(&x);
             match min {
@@ -905,7 +905,7 @@ pub trait OrdIterator<A> {
     fn min_max(&mut self) -> MinMaxResult<A>;
 }
 
-impl<A: TotalOrd, T: Iterator<A>> OrdIterator<A> for T {
+impl<A: Ord, T: Iterator<A>> OrdIterator<A> for T {
     #[inline]
     fn max(&mut self) -> Option<A> {
         self.fold(None, |max, x| {
@@ -2182,12 +2182,12 @@ impl<A: Clone> RandomAccessIterator<A> for Repeat<A> {
 /// the shorter sequence compares less.
 pub mod order {
     use cmp;
-    use cmp::{TotalEq, TotalOrd, PartialOrd, PartialEq};
+    use cmp::{Eq, Ord, PartialOrd, PartialEq};
     use option::{Some, None};
     use super::Iterator;
 
-    /// Compare `a` and `b` for equality using `TotalEq`
-    pub fn equals<A: TotalEq, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
+    /// Compare `a` and `b` for equality using `Eq`
+    pub fn equals<A: Eq, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
         loop {
             match (a.next(), b.next()) {
                 (None, None) => return true,
@@ -2197,8 +2197,8 @@ pub mod order {
         }
     }
 
-    /// Order `a` and `b` lexicographically using `TotalOrd`
-    pub fn cmp<A: TotalOrd, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> cmp::Ordering {
+    /// Order `a` and `b` lexicographically using `Ord`
+    pub fn cmp<A: Ord, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> cmp::Ordering {
         loop {
             match (a.next(), b.next()) {
                 (None, None) => return cmp::Equal,
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 379d14a6e6a..b91a8cebded 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -141,14 +141,14 @@
 //! }
 //! ```
 
-use cmp::{PartialEq, TotalEq, TotalOrd};
+use cmp::{PartialEq, Eq, Ord};
 use default::Default;
 use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
 use mem;
 use slice;
 
 /// The `Option`
-#[deriving(Clone, PartialEq, PartialOrd, TotalEq, TotalOrd, Show)]
+#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show)]
 pub enum Option<T> {
     /// No value
     None,
diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs
index 466f981c926..a6a8319ca02 100644
--- a/src/libcore/prelude.rs
+++ b/src/libcore/prelude.rs
@@ -45,7 +45,7 @@ pub use mem::drop;
 
 pub use char::Char;
 pub use clone::Clone;
-pub use cmp::{PartialEq, PartialOrd, TotalEq, TotalOrd};
+pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
 pub use cmp::{Ordering, Less, Equal, Greater, Equiv};
 pub use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
 pub use iter::{FromIterator, Extendable};
@@ -59,6 +59,6 @@ pub use str::{Str, StrSlice};
 pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
 pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
 pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
-pub use slice::{ImmutableEqVector, ImmutableTotalOrdVector};
+pub use slice::{ImmutableEqVector, ImmutableOrdVector};
 pub use slice::{MutableVector};
 pub use slice::{Vector, ImmutableVector};
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index 442838b3d08..dacbba61856 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -93,7 +93,7 @@ use intrinsics;
 use iter::{range, Iterator};
 use option::{Some, None, Option};
 
-#[cfg(not(test))] use cmp::{PartialEq, TotalEq, PartialOrd, Equiv};
+#[cfg(not(test))] use cmp::{PartialEq, Eq, PartialOrd, Equiv};
 
 /// Return the offset of the first null pointer in `buf`.
 #[inline]
@@ -396,7 +396,7 @@ impl<T> PartialEq for *T {
 }
 
 #[cfg(not(test))]
-impl<T> TotalEq for *T {}
+impl<T> Eq for *T {}
 
 #[cfg(not(test))]
 impl<T> PartialEq for *mut T {
@@ -409,7 +409,7 @@ impl<T> PartialEq for *mut T {
 }
 
 #[cfg(not(test))]
-impl<T> TotalEq for *mut T {}
+impl<T> Eq for *mut T {}
 
 // Equivalence for pointers
 #[cfg(not(test))]
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 8928fa0ee04..c19c5d3145a 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -283,7 +283,7 @@ use option::{None, Option, Some};
 /// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
 ///
 /// See the [`std::result`](index.html) module documentation for details.
-#[deriving(Clone, PartialEq, PartialOrd, TotalEq, TotalOrd, Show)]
+#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show)]
 #[must_use]
 pub enum Result<T, E> {
     /// Contains the success value
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs
index 8f885dafffa..5673d0c020d 100644
--- a/src/libcore/slice.rs
+++ b/src/libcore/slice.rs
@@ -17,7 +17,7 @@
 use mem::transmute;
 use clone::Clone;
 use container::Container;
-use cmp::{PartialEq, TotalOrd, Ordering, Less, Equal, Greater};
+use cmp::{PartialEq, Ord, Ordering, Less, Equal, Greater};
 use cmp;
 use default::Default;
 use iter::*;
@@ -251,7 +251,7 @@ impl<'a, T> RandomAccessIterator<&'a [T]> for Chunks<'a, T> {
 pub mod traits {
     use super::*;
 
-    use cmp::{PartialEq, PartialOrd, TotalEq, TotalOrd, Ordering, Equiv};
+    use cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering, Equiv};
     use iter::{order, Iterator};
     use container::Container;
 
@@ -273,9 +273,9 @@ pub mod traits {
         fn ne(&self, other: &~[T]) -> bool { !self.eq(other) }
     }
 
-    impl<'a,T:TotalEq> TotalEq for &'a [T] {}
+    impl<'a,T:Eq> Eq for &'a [T] {}
 
-    impl<T:TotalEq> TotalEq for ~[T] {}
+    impl<T:Eq> Eq for ~[T] {}
 
     impl<'a,T:PartialEq, V: Vector<T>> Equiv<V> for &'a [T] {
         #[inline]
@@ -287,13 +287,13 @@ pub mod traits {
         fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
     }
 
-    impl<'a,T:TotalOrd> TotalOrd for &'a [T] {
+    impl<'a,T:Ord> Ord for &'a [T] {
         fn cmp(&self, other: & &'a [T]) -> Ordering {
             order::cmp(self.iter(), other.iter())
         }
     }
 
-    impl<T: TotalOrd> TotalOrd for ~[T] {
+    impl<T: Ord> Ord for ~[T] {
         #[inline]
         fn cmp(&self, other: &~[T]) -> Ordering { self.as_slice().cmp(&other.as_slice()) }
     }
@@ -741,8 +741,8 @@ impl<'a,T:PartialEq> ImmutableEqVector<T> for &'a [T] {
     }
 }
 
-/// Extension methods for vectors containing `TotalOrd` elements.
-pub trait ImmutableTotalOrdVector<T: TotalOrd> {
+/// Extension methods for vectors containing `Ord` elements.
+pub trait ImmutableOrdVector<T: Ord> {
     /**
      * Binary search a sorted vector for a given element.
      *
@@ -751,7 +751,7 @@ pub trait ImmutableTotalOrdVector<T: TotalOrd> {
     fn bsearch_elem(&self, x: &T) -> Option<uint>;
 }
 
-impl<'a, T: TotalOrd> ImmutableTotalOrdVector<T> for &'a [T] {
+impl<'a, T: Ord> ImmutableOrdVector<T> for &'a [T] {
     fn bsearch_elem(&self, x: &T) -> Option<uint> {
         self.bsearch(|p| p.cmp(x))
     }
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 21dbaf70597..c83b1d09283 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -18,7 +18,7 @@ use mem;
 use char;
 use clone::Clone;
 use cmp;
-use cmp::{PartialEq, TotalEq};
+use cmp::{PartialEq, Eq};
 use container::Container;
 use default::Default;
 use iter::{Filter, Map, Iterator};
@@ -698,7 +698,7 @@ pub struct Utf16Items<'a> {
     iter: slice::Items<'a, u16>
 }
 /// The possibilities for values decoded from a `u16` stream.
-#[deriving(PartialEq, TotalEq, Clone, Show)]
+#[deriving(PartialEq, Eq, Clone, Show)]
 pub enum Utf16Item {
     /// A valid codepoint.
     ScalarValue(char),
@@ -932,12 +932,12 @@ Section: Trait implementations
 #[allow(missing_doc)]
 pub mod traits {
     use container::Container;
-    use cmp::{TotalOrd, Ordering, Less, Equal, Greater, PartialEq, PartialOrd, Equiv, TotalEq};
+    use cmp::{Ord, Ordering, Less, Equal, Greater, PartialEq, PartialOrd, Equiv, Eq};
     use iter::Iterator;
     use option::{Some, None};
     use str::{Str, StrSlice, eq_slice};
 
-    impl<'a> TotalOrd for &'a str {
+    impl<'a> Ord for &'a str {
         #[inline]
         fn cmp(&self, other: & &'a str) -> Ordering {
             for (s_b, o_b) in self.bytes().zip(other.bytes()) {
@@ -961,7 +961,7 @@ pub mod traits {
         fn ne(&self, other: & &'a str) -> bool { !(*self).eq(other) }
     }
 
-    impl<'a> TotalEq for &'a str {}
+    impl<'a> Eq for &'a str {}
 
     impl<'a> PartialOrd for &'a str {
         #[inline]
diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs
index f9a14b1de50..c8cbd49aa89 100644
--- a/src/libcore/tuple.rs
+++ b/src/libcore/tuple.rs
@@ -28,9 +28,9 @@
 //!
 //! * `Clone`
 //! * `PartialEq`
-//! * `TotalEq`
+//! * `Eq`
 //! * `PartialOrd`
-//! * `TotalOrd`
+//! * `Ord`
 //! * `Default`
 //!
 //! # Examples
@@ -123,7 +123,7 @@ macro_rules! tuple_impls {
             }
 
             #[cfg(not(test))]
-            impl<$($T:TotalEq),+> TotalEq for ($($T,)+) {}
+            impl<$($T:Eq),+> Eq for ($($T,)+) {}
 
             #[cfg(not(test))]
             impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+) {
@@ -146,7 +146,7 @@ macro_rules! tuple_impls {
             }
 
             #[cfg(not(test))]
-            impl<$($T:TotalOrd),+> TotalOrd for ($($T,)+) {
+            impl<$($T:Ord),+> Ord for ($($T,)+) {
                 #[inline]
                 fn cmp(&self, other: &($($T,)+)) -> Ordering {
                     lexical_cmp!($(self.$refN(), other.$refN()),+)
@@ -364,7 +364,7 @@ mod tests {
         assert!(((1.0, 2.0) < (2.0, nan)));
         assert!(!((2.0, 2.0) < (2.0, nan)));
 
-        // TotalOrd
+        // Ord
         assert!(small.cmp(&small) == Equal);
         assert!(big.cmp(&big) == Equal);
         assert!(small.cmp(&big) == Less);