From b94bcbf56eab163517e8ffc93888284b8dbb6238 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Tue, 30 Dec 2014 14:44:26 -0800 Subject: 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] --- src/liballoc/arc.rs | 8 ++++---- src/liballoc/boxed.rs | 6 +++++- src/liballoc/rc.rs | 8 ++++---- 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/liballoc') 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 Drop for Weak { } } -#[unstable = "waiting on PartialEq"] +#[stable] impl PartialEq for Arc { /// Equality for two `Arc`s. /// @@ -490,7 +490,7 @@ impl PartialEq for Arc { /// ``` fn ne(&self, other: &Arc) -> bool { *(*self) != *(*other) } } -#[unstable = "waiting on PartialOrd"] +#[stable] impl PartialOrd for Arc { /// Partial comparison for two `Arc`s. /// @@ -569,11 +569,11 @@ impl PartialOrd for Arc { /// ``` fn ge(&self, other: &Arc) -> bool { *(*self) >= *(*other) } } -#[unstable = "waiting on Ord"] +#[stable] impl Ord for Arc { fn cmp(&self, other: &Arc) -> Ordering { (**self).cmp(&**other) } } -#[unstable = "waiting on Eq"] +#[stable] impl Eq for Arc {} impl fmt::Show for Arc { 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 Clone for Box { } } +#[stable] impl PartialEq for Box { #[inline] fn eq(&self, other: &Box) -> bool { PartialEq::eq(&**self, &**other) } #[inline] fn ne(&self, other: &Box) -> bool { PartialEq::ne(&**self, &**other) } } +#[stable] impl PartialOrd for Box { #[inline] fn partial_cmp(&self, other: &Box) -> Option { @@ -92,12 +94,14 @@ impl PartialOrd for Box { #[inline] fn gt(&self, other: &Box) -> bool { PartialOrd::gt(&**self, &**other) } } +#[stable] impl Ord for Box { #[inline] fn cmp(&self, other: &Box) -> Ordering { Ord::cmp(&**self, &**other) } -} + +#[stable]} impl Eq for Box {} impl> Hash for Box { 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 Default for Rc { } } -#[unstable = "PartialEq is unstable."] +#[stable] impl PartialEq for Rc { /// Equality for two `Rc`s. /// @@ -487,10 +487,10 @@ impl PartialEq for Rc { fn ne(&self, other: &Rc) -> bool { **self != **other } } -#[unstable = "Eq is unstable."] +#[stable] impl Eq for Rc {} -#[unstable = "PartialOrd is unstable."] +#[stable] impl PartialOrd for Rc { /// Partial comparison for two `Rc`s. /// @@ -575,7 +575,7 @@ impl PartialOrd for Rc { fn ge(&self, other: &Rc) -> bool { **self >= **other } } -#[unstable = "Ord is unstable."] +#[stable] impl Ord for Rc { /// Comparison for two `Rc`s. /// -- cgit 1.4.1-3-g733a5