From f0df71c6cbc3b4015995a255927992a70900307a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 18 Nov 2022 10:02:04 +0100 Subject: [PATCH] FlexZeroSlize: implement Eq and PartialEq by hand --- utils/zerovec/src/flexzerovec/slice.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/zerovec/src/flexzerovec/slice.rs b/utils/zerovec/src/flexzerovec/slice.rs index 7cc6f12fa7c..ee164d05bde 100644 --- a/utils/zerovec/src/flexzerovec/slice.rs +++ b/utils/zerovec/src/flexzerovec/slice.rs @@ -14,7 +14,6 @@ const USIZE_WIDTH: usize = mem::size_of::(); /// A zero-copy "slice" that efficiently represents `[usize]`. #[repr(packed)] -#[derive(Eq, PartialEq)] pub struct FlexZeroSlice { // Hard Invariant: 1 <= width <= USIZE_WIDTH (which is target_pointer_width) // Soft Invariant: width == the width of the largest element @@ -23,6 +22,13 @@ pub struct FlexZeroSlice { data: [u8], } +impl PartialEq for FlexZeroSlice { + fn eq(&self, other: &Self) -> bool { + self.width == other.width && self.data == other.data + } +} +impl Eq for FlexZeroSlice {} + /// Helper function to decode a little-endian "chunk" (byte slice of a specific length) /// into a `usize`. We cannot call `usize::from_le_bytes` directly because that function /// requires the high bits to be set to 0.