From b788e934fe738f3a99e2c7453230d8b6b9294953 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Wed, 16 Aug 2023 01:51:13 +0300 Subject: [PATCH] feat: add missing `PartialEq` impls and blanket `From` impl for `MenuId` --- .changes/impls.md | 5 +++++ src/tray_icon_id.rs | 24 +++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 .changes/impls.md diff --git a/.changes/impls.md b/.changes/impls.md new file mode 100644 index 0000000..69bd0af --- /dev/null +++ b/.changes/impls.md @@ -0,0 +1,5 @@ +--- +"tray-icon": "patch" +--- + +Add `PartialEq<&str> for &TrayIconId` and `PartialEq for &TrayIconId` implementations. Also add a blanket `From for TrayIconId` where `T: ToString` implementation. diff --git a/src/tray_icon_id.rs b/src/tray_icon_id.rs index 5b623d3..194c335 100644 --- a/src/tray_icon_id.rs +++ b/src/tray_icon_id.rs @@ -17,15 +17,9 @@ impl AsRef for TrayIconId { } } -impl From for TrayIconId { - fn from(value: String) -> Self { - Self::new(value) - } -} - -impl From<&str> for TrayIconId { - fn from(value: &str) -> Self { - Self::new(value) +impl From for TrayIconId { + fn from(value: T) -> Self { + Self::new(value.to_string()) } } @@ -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 for TrayIconId { fn eq(&self, other: &String) -> bool { self.0 == *other } } +impl PartialEq 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