From 3ac6f546c35f30aec5e67519d0165012696e659d Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Tue, 19 Nov 2024 11:58:00 +1100 Subject: [PATCH] Remove unnecessary type bounds on derive --- ssz/src/bitfield.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ssz/src/bitfield.rs b/ssz/src/bitfield.rs index ce5b442..c53ff9c 100644 --- a/ssz/src/bitfield.rs +++ b/ssz/src/bitfield.rs @@ -110,7 +110,7 @@ pub type BitVector = Bitfield>; /// The internal representation of the bitfield is the same as that required by SSZ. The lowest /// byte (by `Vec` index) stores the lowest bit-indices and the right-most bit stores the lowest /// bit-index. E.g., `smallvec![0b0000_0001, 0b0000_0010]` has bits `0, 9` set. -#[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, Debug)] pub struct Bitfield { bytes: SmallVec<[u8; SMALLVEC_LEN]>, len: usize, @@ -544,6 +544,22 @@ impl Bitfield { } } +impl Eq for Bitfield {} +impl PartialEq for Bitfield { + #[inline] + fn eq(&self, other: &Bitfield) -> bool { + self.len == other.len && self.bytes == other.bytes + } +} + +impl core::hash::Hash for Bitfield { + #[inline] + fn hash(&self, state: &mut H) { + core::hash::Hash::hash(&self.bytes, state); + core::hash::Hash::hash(&self.len, state); + } +} + /// Returns the minimum required bytes to represent a given number of bits. /// /// `bit_len == 0` requires a single byte.