feat: add missing PartialEq impls and blanket From impl for MenuId (#100)

This commit is contained in:
Amr Bashir 2023-08-16 02:03:39 +03:00 committed by GitHub
parent 33168fa0a0
commit 1a527e8708
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 9 deletions

View file

@ -0,0 +1,5 @@
---
"muda": "patch"
---
Add `PartialEq<&str> for &MenuId` and `PartialEq<String> for &MenuId` implementations. Also add a blanket `From<T> for MenuId` where `T: ToString` implementation.

View file

@ -17,15 +17,9 @@ impl AsRef<str> for MenuId {
} }
} }
impl From<String> for MenuId { impl<T: ToString> From<T> for MenuId {
fn from(value: String) -> Self { fn from(value: T) -> Self {
Self::new(value) Self::new(value.to_string())
}
}
impl From<&str> for MenuId {
fn from(value: &str) -> Self {
Self::new(value)
} }
} }
@ -43,12 +37,24 @@ impl PartialEq<&str> for MenuId {
} }
} }
impl PartialEq<&str> for &MenuId {
fn eq(&self, other: &&str) -> bool {
self.0 == *other
}
}
impl PartialEq<String> for MenuId { impl PartialEq<String> for MenuId {
fn eq(&self, other: &String) -> bool { fn eq(&self, other: &String) -> bool {
self.0 == *other self.0 == *other
} }
} }
impl PartialEq<String> for &MenuId {
fn eq(&self, other: &String) -> bool {
self.0 == *other
}
}
impl PartialEq<&String> for MenuId { impl PartialEq<&String> for MenuId {
fn eq(&self, other: &&String) -> bool { fn eq(&self, other: &&String) -> bool {
self.0 == **other self.0 == **other