Skip to content

Commit

Permalink
Add impl PhfHash for integer slices
Browse files Browse the repository at this point in the history
Currently it's impossible to use `[u64; N]` as a type for example because that gets borrowed as an `[u64]` and there is no `PhfHash` implementation for that.
  • Loading branch information
drewkett committed Nov 16, 2022
1 parent 1b88e07 commit 272f3d7
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions phf_shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,30 @@ array_impl!(u128);
array_impl!(i128);
array_impl!(bool);
array_impl!(char);

macro_rules! slice_impl (
($t:ty) => {
impl PhfHash for [$t] {
#[inline]
fn phf_hash<H: Hasher>(&self, state: &mut H) {
for v in self {
v.phf_hash(state);
}
}
}
};
);

slice_impl!(i8);
slice_impl!(u16);
slice_impl!(i16);
slice_impl!(u32);
slice_impl!(i32);
slice_impl!(u64);
slice_impl!(i64);
slice_impl!(usize);
slice_impl!(isize);
slice_impl!(u128);
slice_impl!(i128);
slice_impl!(bool);
slice_impl!(char);

0 comments on commit 272f3d7

Please sign in to comment.