Skip to content

Commit

Permalink
feat: add missing PartialEq impls and blanket From impl for MenuId
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Aug 15, 2023
1 parent 5b92d1f commit b788e93
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changes/impls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tray-icon": "patch"
---

Add `PartialEq<&str> for &TrayIconId` and `PartialEq<String> for &TrayIconId` implementations. Also add a blanket `From<T> for TrayIconId` where `T: ToString` implementation.
24 changes: 15 additions & 9 deletions src/tray_icon_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@ impl AsRef<str> for TrayIconId {
}
}

impl From<String> for TrayIconId {
fn from(value: String) -> Self {
Self::new(value)
}
}

impl From<&str> for TrayIconId {
fn from(value: &str) -> Self {
Self::new(value)
impl<T: ToString> From<T> for TrayIconId {
fn from(value: T) -> Self {
Self::new(value.to_string())
}
}

Expand All @@ -43,12 +37,24 @@ impl PartialEq<&str> for TrayIconId {
}
}

impl PartialEq<&str> for &TrayIconId {
fn eq(&self, other: &&str) -> bool {
self.0 == *other
}
}

impl PartialEq<String> for TrayIconId {
fn eq(&self, other: &String) -> bool {
self.0 == *other
}
}

impl PartialEq<String> for &TrayIconId {
fn eq(&self, other: &String) -> bool {
self.0 == *other
}
}

impl PartialEq<&String> for TrayIconId {
fn eq(&self, other: &&String) -> bool {
self.0 == **other
Expand Down

0 comments on commit b788e93

Please sign in to comment.