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:
commit
44cb86bdc8
12 changed files with 34 additions and 66 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue