envzn
0.8 · beta · not released

Library / Hashing / Hashing / Hasher

INTERFACEEXTENDS Cloneable

Hasher

Hasher Distinct in shape from Hashable: Hashable is "this type knows how to hash itself" (hash() on SELF); Hasher OF K is "this object knows how to hash values of type K" (hash(K key) on a separate hasher instance). The latter is the contract for pluggable hashing — a Dictionary / Set may be constructed with a custom Hasher, and when none is supplied the impl constructs a kernel default that delegates to the key's own Hashable.hash().

Methods 2

METHOD clone() RETURNS Hasher[K]
reads
METHOD hash(REFERENCE K key) RETURNS uint64
reads

The key is BORROWED, not taken. A bare K key parameter is a type-parameter param, which emits by value — so every call site materialises an owned K (_ev_duplicate) just to compute a hash. Hashing only reads, so it borrows.