use core::hash::{Hash, Hasher};
struct FnvHasher(u64);
impl Hasher for FnvHasher {
fn finish(&self) -> u64 {
self.0
}
fn write(&mut self, bytes: &[u8]) {
for b in bytes {
self.0 ^= *b as u64;
self.0 = self.0.wrapping_mul(0x100000001b3);
}
}
}
pub fn hash_value<T: Hash + ?Sized>(value: &T) -> u64 {
let mut h = FnvHasher(0xcbf29ce484222325);
value.hash(&mut h);
h.finish()
}
pub trait FieldDiff: Hash {
type Path: Copy + Eq + Hash + Send + Sync + 'static;
fn field_hashes(&self, out: &mut alloc::vec::Vec<(Self::Path, u64)>);
}