Implement string comparison for identifier types
This commit is contained in:
parent
3945f88e10
commit
fe70d158e7
@ -80,5 +80,29 @@ macro_rules! common_impls {
|
||||
crate::deserialize_id(deserializer, $desc)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::cmp::PartialEq<str> for $id {
|
||||
fn eq(&self, other: &str) -> bool {
|
||||
self.full_id == other
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::cmp::PartialEq<$id> for str {
|
||||
fn eq(&self, other: &$id) -> bool {
|
||||
self == other.full_id
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::cmp::PartialEq<::std::string::String> for $id {
|
||||
fn eq(&self, other: &::std::string::String) -> bool {
|
||||
&self.full_id == other
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::cmp::PartialEq<$id> for ::string::String {
|
||||
fn eq(&self, other: &$id) -> bool {
|
||||
self == &other.full_id
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -215,6 +215,30 @@ impl TryFrom<String> for RoomVersionId {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<str> for RoomVersionId {
|
||||
fn eq(&self, other: &str) -> bool {
|
||||
self.as_ref() == other
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<RoomVersionId> for str {
|
||||
fn eq(&self, other: &RoomVersionId) -> bool {
|
||||
self == other.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<String> for RoomVersionId {
|
||||
fn eq(&self, other: &String) -> bool {
|
||||
self.as_ref() == other
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<RoomVersionId> for String {
|
||||
fn eq(&self, other: &RoomVersionId) -> bool {
|
||||
self == other.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::convert::TryFrom;
|
||||
|
Loading…
x
Reference in New Issue
Block a user