diff options
| author | Aaron Turon <aturon@mozilla.com> | 2014-12-30 14:44:26 -0800 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2014-12-30 14:44:26 -0800 |
| commit | b94bcbf56eab163517e8ffc93888284b8dbb6238 (patch) | |
| tree | 7a18c863cc94c86dd6ba2d9813af0d0af2b5b512 /src/liballoc | |
| parent | 84f5ad8679c7fc454473ffbf389030f3e5fee379 (diff) | |
| download | rust-b94bcbf56eab163517e8ffc93888284b8dbb6238.tar.gz rust-b94bcbf56eab163517e8ffc93888284b8dbb6238.zip | |
Stabilize cmp
This patch marks `PartialEq`, `Eq`, `PartialOrd`, and `Ord` as `#[stable]`, as well as the majorify of manual implementaitons of these traits. The traits match the [reform RFC](https://github.com/rust-lang/rfcs/pull/439). Along the way, two changes are made: * The recently-added type parameters for `Ord` and `Eq` are removed. These were mistakenly added while adding them to `PartialOrd` and `PartialEq`, but they don't make sense given the laws that are required for (and use cases for) `Ord` and `Eq`. * More explicit laws are added for `PartialEq` and `PartialOrd`, connecting them to their associated mathematical concepts. In the future, many of the impls should be generalized; see since generalizing later is not a breaking change. [breaking-change]
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/arc.rs | 8 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 6 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 8 |
3 files changed, 13 insertions, 9 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 21c47cdf3d7..f6f83f22f92 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -458,7 +458,7 @@ impl<T: Sync + Send> Drop for Weak<T> { } } -#[unstable = "waiting on PartialEq"] +#[stable] impl<T: PartialEq> PartialEq for Arc<T> { /// Equality for two `Arc<T>`s. /// @@ -490,7 +490,7 @@ impl<T: PartialEq> PartialEq for Arc<T> { /// ``` fn ne(&self, other: &Arc<T>) -> bool { *(*self) != *(*other) } } -#[unstable = "waiting on PartialOrd"] +#[stable] impl<T: PartialOrd> PartialOrd for Arc<T> { /// Partial comparison for two `Arc<T>`s. /// @@ -569,11 +569,11 @@ impl<T: PartialOrd> PartialOrd for Arc<T> { /// ``` fn ge(&self, other: &Arc<T>) -> bool { *(*self) >= *(*other) } } -#[unstable = "waiting on Ord"] +#[stable] impl<T: Ord> Ord for Arc<T> { fn cmp(&self, other: &Arc<T>) -> Ordering { (**self).cmp(&**other) } } -#[unstable = "waiting on Eq"] +#[stable] impl<T: Eq> Eq for Arc<T> {} impl<T: fmt::Show> fmt::Show for Arc<T> { diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 3c6b2d2cbc0..74f0599e486 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -72,12 +72,14 @@ impl<T: Clone> Clone for Box<T> { } } +#[stable] impl<Sized? T: PartialEq> PartialEq for Box<T> { #[inline] fn eq(&self, other: &Box<T>) -> bool { PartialEq::eq(&**self, &**other) } #[inline] fn ne(&self, other: &Box<T>) -> bool { PartialEq::ne(&**self, &**other) } } +#[stable] impl<Sized? T: PartialOrd> PartialOrd for Box<T> { #[inline] fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> { @@ -92,12 +94,14 @@ impl<Sized? T: PartialOrd> PartialOrd for Box<T> { #[inline] fn gt(&self, other: &Box<T>) -> bool { PartialOrd::gt(&**self, &**other) } } +#[stable] impl<Sized? T: Ord> Ord for Box<T> { #[inline] fn cmp(&self, other: &Box<T>) -> Ordering { Ord::cmp(&**self, &**other) } -} + +#[stable]} impl<Sized? T: Eq> Eq for Box<T> {} impl<S: hash::Writer, Sized? T: Hash<S>> Hash<S> for Box<T> { diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 214fae02ce2..75d4342083b 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -452,7 +452,7 @@ impl<T: Default> Default for Rc<T> { } } -#[unstable = "PartialEq is unstable."] +#[stable] impl<T: PartialEq> PartialEq for Rc<T> { /// Equality for two `Rc<T>`s. /// @@ -487,10 +487,10 @@ impl<T: PartialEq> PartialEq for Rc<T> { fn ne(&self, other: &Rc<T>) -> bool { **self != **other } } -#[unstable = "Eq is unstable."] +#[stable] impl<T: Eq> Eq for Rc<T> {} -#[unstable = "PartialOrd is unstable."] +#[stable] impl<T: PartialOrd> PartialOrd for Rc<T> { /// Partial comparison for two `Rc<T>`s. /// @@ -575,7 +575,7 @@ impl<T: PartialOrd> PartialOrd for Rc<T> { fn ge(&self, other: &Rc<T>) -> bool { **self >= **other } } -#[unstable = "Ord is unstable."] +#[stable] impl<T: Ord> Ord for Rc<T> { /// Comparison for two `Rc<T>`s. /// |
