diff --git a/crates/ruma-macros/src/identifiers.rs b/crates/ruma-macros/src/identifiers.rs index 69d6a18a..06d03be7 100644 --- a/crates/ruma-macros/src/identifiers.rs +++ b/crates/ruma-macros/src/identifiers.rs @@ -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> for #owned { fn eq(&self, other: &Box<#id>) -> bool { AsRef::<#id>::as_ref(self) == AsRef::<#id>::as_ref(other)