identifiers: Add extra PartialEq implementations for owned ID types

This commit is contained in:
Jonas Platte 2022-04-14 11:03:55 +02:00
parent d36157a57c
commit 5d8f6748e6
No known key found for this signature in database
GPG Key ID: BBA95679259D342F

View File

@ -282,6 +282,30 @@ fn expand_owned_id(id: &Ident, owned: &Ident) -> TokenStream {
#partial_eq_string
impl PartialEq<#id> for #owned {
fn eq(&self, other: &#id) -> bool {
AsRef::<#id>::as_ref(self) == other
}
}
impl PartialEq<#owned> for #id {
fn eq(&self, other: &#owned) -> bool {
self == AsRef::<#id>::as_ref(other)
}
}
impl PartialEq<&#id> for #owned {
fn eq(&self, other: &&#id) -> bool {
AsRef::<#id>::as_ref(self) == *other
}
}
impl PartialEq<#owned> for &#id {
fn eq(&self, other: &#owned) -> bool {
*self == AsRef::<#id>::as_ref(other)
}
}
impl PartialEq<Box<#id>> for #owned {
fn eq(&self, other: &Box<#id>) -> bool {
AsRef::<#id>::as_ref(self) == AsRef::<#id>::as_ref(other)