Skip to main content

HashContext

Trait HashContext 

Source
pub trait HashContext<K> {
    // Required methods
    fn hash(&self, key: &K) -> u64;
    fn eq(&self, a: &K, b: &K) -> bool;
}
Expand description

Provides hashing and equality for keys of type K.

Implementors replace the standard Hash + Eq trait combination, allowing custom hash functions without needing newtype wrappers.

§Contract

  • If eq(a, b) returns true, then hash(a) == hash(b) must also hold.
  • eq must be an equivalence relation (reflexive, symmetric, transitive).

Required Methods§

Source

fn hash(&self, key: &K) -> u64

Returns the 64-bit hash of key.

Source

fn eq(&self, a: &K, b: &K) -> bool

Returns true if a and b should be considered equal keys.

Implementors§