From 25075ec77030c918d3c331a78ff59f145d3c57c5 Mon Sep 17 00:00:00 2001 From: TimLuq Date: Thu, 1 Aug 2024 11:05:01 +0200 Subject: [PATCH] add another layer of PartialEq indirection to slices --- src/bytedata.rs | 7 +++++++ src/stringdata.rs | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/bytedata.rs b/src/bytedata.rs index 8f0ccea..e72579f 100644 --- a/src/bytedata.rs +++ b/src/bytedata.rs @@ -775,6 +775,13 @@ impl PartialEq> for [u8] { } } +impl<'a, 'b> PartialEq> for &'b [u8] { + #[inline] + fn eq(&self, other: &ByteData<'a>) -> bool { + (*self).eq(other.as_slice()) + } +} + #[cfg(feature = "alloc")] #[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] impl PartialEq> for ByteData<'_> { diff --git a/src/stringdata.rs b/src/stringdata.rs index 9ed2498..ce44d98 100644 --- a/src/stringdata.rs +++ b/src/stringdata.rs @@ -424,6 +424,20 @@ impl PartialEq> for str { } } +impl<'a, 'b> PartialEq> for &'b str { + #[inline] + fn eq(&self, other: &StringData<'a>) -> bool { + (*self).eq(other.as_str()) + } +} + +impl<'a, 'b> PartialEq> for &'b [u8] { + #[inline] + fn eq(&self, other: &StringData<'a>) -> bool { + (*self).eq(other.as_bytes()) + } +} + #[cfg(feature = "alloc")] #[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] impl PartialEq> for StringData<'_> {