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)returnstrue, thenhash(a) == hash(b)must also hold. eqmust be an equivalence relation (reflexive, symmetric, transitive).
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".