1use crate::HashFn;
2use std::convert::TryInto;
3
4/// A hash function that simply takes the last 4 bytes of a given key as the
5/// hash value.
6#[derive(Eq, PartialEq)]
7pub struct UnHashFn;
8
9impl HashFn for UnHashFn {
10 #[inline]
11 fn hash(bytes: &[u8]) -> u32 {
12 let len: usize = bytes.len();
13 u32::from_le_bytes(bytes[len - 4..].try_into().unwrap())
14 }
15}
16