Skip to content

Commit

Permalink
add another layer of PartialEq indirection to slices
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLuq committed Aug 1, 2024
1 parent 2502a89 commit 25075ec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/bytedata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,13 @@ impl PartialEq<ByteData<'_>> for [u8] {
}
}

impl<'a, 'b> PartialEq<ByteData<'a>> 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<Vec<u8>> for ByteData<'_> {
Expand Down
14 changes: 14 additions & 0 deletions src/stringdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,20 @@ impl PartialEq<StringData<'_>> for str {
}
}

impl<'a, 'b> PartialEq<StringData<'a>> for &'b str {
#[inline]
fn eq(&self, other: &StringData<'a>) -> bool {
(*self).eq(other.as_str())
}
}

impl<'a, 'b> PartialEq<StringData<'a>> 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<Vec<u8>> for StringData<'_> {
Expand Down

0 comments on commit 25075ec

Please sign in to comment.