Skip to content

Commit f576215

Browse files
committed
libcollections: DRY up a PartialEq impl for String
1 parent cc830ef commit f576215

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

src/libcollections/string.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -963,15 +963,15 @@ impl PartialEq for String {
963963
macro_rules! impl_eq {
964964
($lhs:ty, $rhs: ty) => {
965965
#[stable(feature = "rust1", since = "1.0.0")]
966-
impl<'a> PartialEq<$rhs> for $lhs {
966+
impl<'a, 'b> PartialEq<$rhs> for $lhs {
967967
#[inline]
968968
fn eq(&self, other: &$rhs) -> bool { PartialEq::eq(&self[..], &other[..]) }
969969
#[inline]
970970
fn ne(&self, other: &$rhs) -> bool { PartialEq::ne(&self[..], &other[..]) }
971971
}
972972

973973
#[stable(feature = "rust1", since = "1.0.0")]
974-
impl<'a> PartialEq<$lhs> for $rhs {
974+
impl<'a, 'b> PartialEq<$lhs> for $rhs {
975975
#[inline]
976976
fn eq(&self, other: &$lhs) -> bool { PartialEq::eq(&self[..], &other[..]) }
977977
#[inline]
@@ -984,24 +984,9 @@ macro_rules! impl_eq {
984984
impl_eq! { String, str }
985985
impl_eq! { String, &'a str }
986986
impl_eq! { Cow<'a, str>, str }
987+
impl_eq! { Cow<'a, str>, &'b str }
987988
impl_eq! { Cow<'a, str>, String }
988989

989-
#[stable(feature = "rust1", since = "1.0.0")]
990-
impl<'a, 'b> PartialEq<&'b str> for Cow<'a, str> {
991-
#[inline]
992-
fn eq(&self, other: &&'b str) -> bool { PartialEq::eq(&self[..], &other[..]) }
993-
#[inline]
994-
fn ne(&self, other: &&'b str) -> bool { PartialEq::ne(&self[..], &other[..]) }
995-
}
996-
997-
#[stable(feature = "rust1", since = "1.0.0")]
998-
impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b str {
999-
#[inline]
1000-
fn eq(&self, other: &Cow<'a, str>) -> bool { PartialEq::eq(&self[..], &other[..]) }
1001-
#[inline]
1002-
fn ne(&self, other: &Cow<'a, str>) -> bool { PartialEq::ne(&self[..], &other[..]) }
1003-
}
1004-
1005990
#[stable(feature = "rust1", since = "1.0.0")]
1006991
impl Default for String {
1007992
#[inline]

0 commit comments

Comments
 (0)