From 7fc91f41d8bd948cef3085d7c0d0ec92d1b2bc53 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 13 Aug 2018 16:07:05 +0300 Subject: Generalize query --- crates/smol_str/src/lib.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'crates/smol_str/src') diff --git a/crates/smol_str/src/lib.rs b/crates/smol_str/src/lib.rs index 41c3a39ef..79b179ef4 100644 --- a/crates/smol_str/src/lib.rs +++ b/crates/smol_str/src/lib.rs @@ -49,6 +49,30 @@ impl<'a> PartialEq for &'a str { } } +impl PartialEq for SmolStr { + fn eq(&self, other: &String) -> bool { + self.as_str() == other + } +} + +impl PartialEq for String { + fn eq(&self, other: &SmolStr) -> bool { + other == self + } +} + +impl<'a> PartialEq<&'a String> for SmolStr { + fn eq(&self, other: &&'a String) -> bool { + self == *other + } +} + +impl<'a> PartialEq for &'a String { + fn eq(&self, other: &SmolStr) -> bool { + *self == other + } +} + impl fmt::Debug for SmolStr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(self.as_str(), f) -- cgit v1.2.3