Rollup merge of #61003 - nnethercote:rm-InternedString-PartialEq-impls, r=petrochenkov

Remove impls for `InternedString`/string equality.

`Symbol` received the same treatment in #60630.

Also, we can derive `PartialEq` for `InternedString`.

r? @petrochenkov
This commit is contained in:
Mazdak Farrokhzad 2019-05-22 03:47:41 +02:00 committed by GitHub
commit 44cb86bdc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 34 additions and 66 deletions

View file

@ -1147,7 +1147,7 @@ impl Encodable for LocalInternedString {
/// assert_ne!(Symbol::gensym("x"), Symbol::gensym("x"))
/// assert_eq!(Symbol::gensym("x").as_interned_str(), Symbol::gensym("x").as_interned_str())
/// ```
#[derive(Clone, Copy, Eq)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct InternedString {
symbol: Symbol,
}
@ -1212,42 +1212,6 @@ impl Ord for InternedString {
}
}
impl<T: std::ops::Deref<Target = str>> PartialEq<T> for InternedString {
fn eq(&self, other: &T) -> bool {
self.with(|string| string == other.deref())
}
}
impl PartialEq<InternedString> for InternedString {
fn eq(&self, other: &InternedString) -> bool {
self.symbol == other.symbol
}
}
impl PartialEq<InternedString> for str {
fn eq(&self, other: &InternedString) -> bool {
other.with(|string| self == string)
}
}
impl<'a> PartialEq<InternedString> for &'a str {
fn eq(&self, other: &InternedString) -> bool {
other.with(|string| *self == string)
}
}
impl PartialEq<InternedString> for String {
fn eq(&self, other: &InternedString) -> bool {
other.with(|string| self == string)
}
}
impl<'a> PartialEq<InternedString> for &'a String {
fn eq(&self, other: &InternedString) -> bool {
other.with(|string| *self == string)
}
}
impl fmt::Debug for InternedString {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.with(|str| fmt::Debug::fmt(&str, f))