Skip to content

Commit

Permalink
Remove unnecessary type bounds on derive
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsproul committed Nov 19, 2024
1 parent a751223 commit 3ac6f54
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion ssz/src/bitfield.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub type BitVector<N> = Bitfield<Fixed<N>>;
/// 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<T> {
bytes: SmallVec<[u8; SMALLVEC_LEN]>,
len: usize,
Expand Down Expand Up @@ -544,6 +544,22 @@ impl<T: BitfieldBehaviour> Bitfield<T> {
}
}

impl<T> Eq for Bitfield<T> {}
impl<T> PartialEq for Bitfield<T> {
#[inline]
fn eq(&self, other: &Bitfield<T>) -> bool {
self.len == other.len && self.bytes == other.bytes
}
}

impl<T> core::hash::Hash for Bitfield<T> {
#[inline]
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
core::hash::Hash::hash(&self.bytes, state);
core::hash::Hash::hash(&self.len, state);

Check warning on line 559 in ssz/src/bitfield.rs

View check run for this annotation

Codecov / codecov/patch

ssz/src/bitfield.rs#L557-L559

Added lines #L557 - L559 were not covered by tests
}
}

/// Returns the minimum required bytes to represent a given number of bits.
///
/// `bit_len == 0` requires a single byte.
Expand Down

0 comments on commit 3ac6f54

Please sign in to comment.