From 206c25e7e7dc1a7adee6dc2563579d48a5fad68c Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 17 Sep 2021 22:18:05 +0200 Subject: [PATCH] identifiers: Add more PartialEq implementations --- crates/ruma-identifiers/src/macros.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/ruma-identifiers/src/macros.rs b/crates/ruma-identifiers/src/macros.rs index 8fe87c49..676f57ad 100644 --- a/crates/ruma-identifiers/src/macros.rs +++ b/crates/ruma-identifiers/src/macros.rs @@ -235,6 +235,30 @@ macro_rules! opaque_identifier_common_impls { } } + impl PartialEq<$id> for Box<$id> { + fn eq(&self, other: &$id) -> bool { + self.as_str() == other.as_str() + } + } + + impl PartialEq<&'_ $id> for Box<$id> { + fn eq(&self, other: &&$id) -> bool { + self.as_str() == other.as_str() + } + } + + impl PartialEq> for $id { + fn eq(&self, other: &Box<$id>) -> bool { + self.as_str() == other.as_str() + } + } + + impl PartialEq> for &'_ $id { + fn eq(&self, other: &Box<$id>) -> bool { + self.as_str() == other.as_str() + } + } + as_str_based_impls!($id); partial_eq_string!($id); partial_eq_string!(Box<$id>);