From 63c01cea2d1fa1125bbe2c9bb54d89e0dbb0c196 Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Thu, 2 Apr 2015 18:50:09 +0300 Subject: [PATCH 1/2] Change PartialEq impls in collections::string to slice notation --- src/libcollections/string.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 7a7725320914f..bce314b6e04a9 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -796,9 +796,9 @@ impl<'a, 'b> Pattern<'a> for &'b String { #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for String { #[inline] - fn eq(&self, other: &String) -> bool { PartialEq::eq(&**self, &**other) } + fn eq(&self, other: &String) -> bool { PartialEq::eq(&self[..], &other[..]) } #[inline] - fn ne(&self, other: &String) -> bool { PartialEq::ne(&**self, &**other) } + fn ne(&self, other: &String) -> bool { PartialEq::ne(&self[..], &other[..]) } } macro_rules! impl_eq { @@ -806,17 +806,17 @@ macro_rules! impl_eq { #[stable(feature = "rust1", since = "1.0.0")] impl<'a> PartialEq<$rhs> for $lhs { #[inline] - fn eq(&self, other: &$rhs) -> bool { PartialEq::eq(&**self, &**other) } + fn eq(&self, other: &$rhs) -> bool { PartialEq::eq(&self[..], &other[..]) } #[inline] - fn ne(&self, other: &$rhs) -> bool { PartialEq::ne(&**self, &**other) } + fn ne(&self, other: &$rhs) -> bool { PartialEq::ne(&self[..], &other[..]) } } #[stable(feature = "rust1", since = "1.0.0")] impl<'a> PartialEq<$lhs> for $rhs { #[inline] - fn eq(&self, other: &$lhs) -> bool { PartialEq::eq(&**self, &**other) } + fn eq(&self, other: &$lhs) -> bool { PartialEq::eq(&self[..], &other[..]) } #[inline] - fn ne(&self, other: &$lhs) -> bool { PartialEq::ne(&**self, &**other) } + fn ne(&self, other: &$lhs) -> bool { PartialEq::ne(&self[..], &other[..]) } } } @@ -828,17 +828,17 @@ impl_eq! { Cow<'a, str>, String } #[stable(feature = "rust1", since = "1.0.0")] impl<'a, 'b> PartialEq<&'b str> for Cow<'a, str> { #[inline] - fn eq(&self, other: &&'b str) -> bool { PartialEq::eq(&**self, &**other) } + fn eq(&self, other: &&'b str) -> bool { PartialEq::eq(&self[..], &other[..]) } #[inline] - fn ne(&self, other: &&'b str) -> bool { PartialEq::ne(&**self, &**other) } + fn ne(&self, other: &&'b str) -> bool { PartialEq::ne(&self[..], &other[..]) } } #[stable(feature = "rust1", since = "1.0.0")] impl<'a, 'b> PartialEq> for &'b str { #[inline] - fn eq(&self, other: &Cow<'a, str>) -> bool { PartialEq::eq(&**self, &**other) } + fn eq(&self, other: &Cow<'a, str>) -> bool { PartialEq::eq(&self[..], &other[..]) } #[inline] - fn ne(&self, other: &Cow<'a, str>) -> bool { PartialEq::ne(&**self, &**other) } + fn ne(&self, other: &Cow<'a, str>) -> bool { PartialEq::ne(&self[..], &other[..]) } } #[unstable(feature = "collections", reason = "waiting on Str stabilization")] From 52340630a6f76eae4e9b605d17c650d57114951e Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Thu, 2 Apr 2015 18:51:14 +0300 Subject: [PATCH 2/2] Implement PartialEq for String and Cow --- src/libcollections/string.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index bce314b6e04a9..8da8cad98a705 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -822,7 +822,9 @@ macro_rules! impl_eq { } } +impl_eq! { String, str } impl_eq! { String, &'a str } +impl_eq! { Cow<'a, str>, str } impl_eq! { Cow<'a, str>, String } #[stable(feature = "rust1", since = "1.0.0")]