Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary type bounds on derive #37

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
/// 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> 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
Loading