Skip to content

Commit

Permalink
impl Hash for ZeroVec
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Sep 24, 2024
1 parent 9c3b12c commit 2f666d4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions utils/zerovec/src/zerovec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,19 @@ where
}
}

impl<T> core::hash::Hash for ZeroVec<'_, T>
where
T: AsULE,
{
/// Hashes a ZeroVec as if hashing the underlying bytes.
///
/// This is acceptable according to the ULE byte equality invariant.
#[inline]
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.as_bytes().hash(state);
}
}

impl<'a, T: AsULE> Default for ZeroVec<'a, T> {
#[inline]
fn default() -> Self {
Expand Down

0 comments on commit 2f666d4

Please sign in to comment.