Make string comparison PartialEq impls work

This commit is contained in:
Jonas Platte 2020-05-01 22:58:26 +02:00
parent a67ba7a729
commit 89f0594a68
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
4 changed files with 19 additions and 11 deletions

View File

@ -1,5 +1,13 @@
# [unreleased]
# 0.16.1
Bug fixes:
* Change `PartialEq` implementations to compare IDs with string literals from `str` to `&str`
* This is technically a breaking change, but the previous implementations were extremely
unlikely to actually be used
# 0.16.0
Breaking changes:

View File

@ -9,7 +9,7 @@ license = "MIT"
name = "ruma-identifiers"
readme = "README.md"
repository = "https://github.com/ruma/ruma-identifiers"
version = "0.16.0"
version = "0.16.1"
edition = "2018"
[package.metadata.docs.rs]

View File

@ -83,15 +83,15 @@ macro_rules! common_impls {
}
}
impl ::std::cmp::PartialEq<str> for $id {
fn eq(&self, other: &str) -> bool {
self.full_id == other
impl ::std::cmp::PartialEq<&str> for $id {
fn eq(&self, other: &&str) -> bool {
self.full_id == *other
}
}
impl ::std::cmp::PartialEq<$id> for str {
impl ::std::cmp::PartialEq<$id> for &str {
fn eq(&self, other: &$id) -> bool {
self == other.full_id
*self == other.full_id
}
}

View File

@ -218,15 +218,15 @@ impl TryFrom<String> for RoomVersionId {
}
}
impl PartialEq<str> for RoomVersionId {
fn eq(&self, other: &str) -> bool {
self.as_ref() == other
impl PartialEq<&str> for RoomVersionId {
fn eq(&self, other: &&str) -> bool {
self.as_ref() == *other
}
}
impl PartialEq<RoomVersionId> for str {
impl PartialEq<RoomVersionId> for &str {
fn eq(&self, other: &RoomVersionId) -> bool {
self == other.as_ref()
*self == other.as_ref()
}
}