From e73ff8c6146830abab5009f48ee3fb87a7a65c12 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Sun, 30 May 2021 15:07:52 -0700 Subject: [PATCH] Impl 'PartialEq>' for 'RawStr'. --- core/http/src/raw_str.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/core/http/src/raw_str.rs b/core/http/src/raw_str.rs index cc9ec9e5..0c4da112 100644 --- a/core/http/src/raw_str.rs +++ b/core/http/src/raw_str.rs @@ -902,12 +902,12 @@ impl From for Cow<'_, RawStr> { } macro_rules! impl_partial { - ($A:ty : $B:ty) => ( + ($A:ty : $B:ty as $T:ty) => ( impl PartialEq<$A> for $B { #[inline(always)] fn eq(&self, other: &$A) -> bool { - let left: &str = self.as_ref(); - let right: &str = other.as_ref(); + let left: $T = self.as_ref(); + let right: $T = other.as_ref(); left == right } } @@ -915,12 +915,13 @@ macro_rules! impl_partial { impl PartialOrd<$A> for $B { #[inline(always)] fn partial_cmp(&self, other: &$A) -> Option { - let left: &str = self.as_ref(); - let right: &str = other.as_ref(); + let left: $T = self.as_ref(); + let right: $T = other.as_ref(); left.partial_cmp(right) } } - ) + ); + ($A:ty : $B:ty) => (impl_partial!($A : $B as &str);) } impl_partial!(RawStr : &RawStr); @@ -933,8 +934,12 @@ impl_partial!(&&str : RawStr); impl_partial!(Cow<'_, str> : RawStr); impl_partial!(Cow<'_, str> : &RawStr); +impl_partial!(Cow<'_, RawStr> : RawStr as &RawStr); +impl_partial!(Cow<'_, RawStr> : &RawStr as &RawStr); impl_partial!(RawStr : Cow<'_, str>); impl_partial!(&RawStr : Cow<'_, str>); +impl_partial!(RawStr : Cow<'_, RawStr> as &RawStr); +impl_partial!(&RawStr : Cow<'_, RawStr> as &RawStr); impl_partial!(String : RawStr); impl_partial!(String : &RawStr);