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 {
fn from(value: String) -> Self {
Self::new(value)
}
}
impl From<&str> for MenuId {
fn from(value: &str) -> Self {
Self::new(value)
impl<T: ToString> From<T> for MenuId {
fn from(value: T) -> Self {
Self::new(value.to_string())
}
}
@ -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 {
fn eq(&self, other: &String) -> bool {
self.0 == *other
}
}
impl PartialEq<String> for &MenuId {
fn eq(&self, other: &String) -> bool {
self.0 == *other
}
}
impl PartialEq<&String> for MenuId {
fn eq(&self, other: &&String) -> bool {
self.0 == **other