Trait hashbrown::Equivalent

source ·
pub trait Equivalent<K: ?Sized> {
    // Required method
    fn equivalent(&self, key: &K) -> bool;
Expand description

Key equivalence trait.

This trait defines the function used to compare the input value with the map keys (or set values) during a lookup operation such as HashMap::get or HashSet::contains. It is provided with a blanket implementation based on the Borrow trait.


Equivalent values must hash to the same value.

Required Methods§


fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key.

Returns true if both values are equivalent, and false otherwise.


When this function returns true, both self and key must hash to the same value.



impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,