1
Fork 0

create a sensible comparison trait hierarchy

* `Ord` inherits from `Eq`
* `TotalOrd` inherits from `TotalEq`
* `TotalOrd` inherits from `Ord`
* `TotalEq` inherits from `Eq`

This is a partial implementation of #12517.
This commit is contained in:
Daniel Micay 2014-02-24 08:11:00 -05:00
parent 33768c46ec
commit 4d7d101a76
29 changed files with 156 additions and 53 deletions

View file

@ -682,7 +682,7 @@ pub mod traits {
fn cmp(&self, other: &~[T]) -> Ordering { self.as_slice().cmp(&other.as_slice()) }
}
impl<'a, T: Eq + Ord> Ord for &'a [T] {
impl<'a, T: Ord> Ord for &'a [T] {
fn lt(&self, other: & &'a [T]) -> bool {
order::lt(self.iter(), other.iter())
}
@ -700,7 +700,7 @@ pub mod traits {
}
}
impl<T: Eq + Ord> Ord for ~[T] {
impl<T: Ord> Ord for ~[T] {
#[inline]
fn lt(&self, other: &~[T]) -> bool { self.as_slice() < other.as_slice() }
#[inline]