about summary refs log tree commit diff
path: root/src/libcollections/string.rs
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2014-12-30 14:44:26 -0800
committerAaron Turon <aturon@mozilla.com>2014-12-30 14:44:26 -0800
commitb94bcbf56eab163517e8ffc93888284b8dbb6238 (patch)
tree7a18c863cc94c86dd6ba2d9813af0d0af2b5b512 /src/libcollections/string.rs
parent84f5ad8679c7fc454473ffbf389030f3e5fee379 (diff)
downloadrust-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/libcollections/string.rs')
-rw-r--r--src/libcollections/string.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index c6c19cae75f..0969f0fcfcc 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -815,6 +815,7 @@ impl<'a> Extend<&'a str> for String {
     }
 }
 
+#[stable]
 impl PartialEq for String {
     #[inline]
     fn eq(&self, other: &String) -> bool { PartialEq::eq(&**self, &**other) }
@@ -824,6 +825,7 @@ impl PartialEq for String {
 
 macro_rules! impl_eq {
     ($lhs:ty, $rhs: ty) => {
+        #[stable]
         impl<'a> PartialEq<$rhs> for $lhs {
             #[inline]
             fn eq(&self, other: &$rhs) -> bool { PartialEq::eq(&**self, &**other) }
@@ -831,6 +833,7 @@ macro_rules! impl_eq {
             fn ne(&self, other: &$rhs) -> bool { PartialEq::ne(&**self, &**other) }
         }
 
+        #[stable]
         impl<'a> PartialEq<$lhs> for $rhs {
             #[inline]
             fn eq(&self, other: &$lhs) -> bool { PartialEq::eq(&**self, &**other) }
@@ -844,6 +847,7 @@ macro_rules! impl_eq {
 impl_eq! { String, &'a str }
 impl_eq! { CowString<'a>, String }
 
+#[stable]
 impl<'a, 'b> PartialEq<&'b str> for CowString<'a> {
     #[inline]
     fn eq(&self, other: &&'b str) -> bool { PartialEq::eq(&**self, &**other) }
@@ -851,6 +855,7 @@ impl<'a, 'b> PartialEq<&'b str> for CowString<'a> {
     fn ne(&self, other: &&'b str) -> bool { PartialEq::ne(&**self, &**other) }
 }
 
+#[stable]
 impl<'a, 'b> PartialEq<CowString<'a>> for &'b str {
     #[inline]
     fn eq(&self, other: &CowString<'a>) -> bool { PartialEq::eq(&**self, &**other) }