Derive ordering from MetaHash: hash both values and compare the digests. For `()` (Anon mode), the hash is empty so all units compare equal.
(a: &T, b: &T)
| 44 | /// Derive ordering from MetaHash: hash both values and compare the digests. |
| 45 | /// For `()` (Anon mode), the hash is empty so all units compare equal. |
| 46 | fn meta_cmp<T: MetaHash>(a: &T, b: &T) -> std::cmp::Ordering { |
| 47 | let hash = |v: &T| { |
| 48 | let mut h = blake3::Hasher::new(); |
| 49 | v.meta_hash(&mut h); |
| 50 | h.finalize() |
| 51 | }; |
| 52 | hash(a).as_bytes().cmp(hash(b).as_bytes()) |
| 53 | } |
| 54 | |
| 55 | impl<M: KernelMode> Hash for KId<M> { |
| 56 | fn hash<H: Hasher>(&self, state: &mut H) { |