key_paths_core/
field_diff.rs1use core::hash::{Hash, Hasher};
4
5struct FnvHasher(u64);
7
8impl Hasher for FnvHasher {
9 fn finish(&self) -> u64 {
10 self.0
11 }
12
13 fn write(&mut self, bytes: &[u8]) {
14 for b in bytes {
15 self.0 ^= *b as u64;
16 self.0 = self.0.wrapping_mul(0x100000001b3);
17 }
18 }
19}
20
21pub fn hash_value<T: Hash + ?Sized>(value: &T) -> u64 {
23 let mut h = FnvHasher(0xcbf29ce484222325);
24 value.hash(&mut h);
25 h.finish()
26}
27
28pub trait FieldDiff: Hash {
31 type Path: Copy + Eq + Hash + Send + Sync + 'static;
33
34 fn field_hashes(&self, out: &mut alloc::vec::Vec<(Self::Path, u64)>);
36}