MCPcopy Create free account
hub / github.com/argumentcomputer/ix / meta_cmp

Function meta_cmp

crates/kernel/src/id.rs:46–53  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
46fn 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
55impl<M: KernelMode> Hash for KId<M> {
56 fn hash<H: Hasher>(&self, state: &mut H) {

Callers 1

cmpMethod · 0.85

Calls 4

finalizeMethod · 0.80
as_bytesMethod · 0.80
meta_hashMethod · 0.45
cmpMethod · 0.45

Tested by

no test coverage detected