pub trait ImmutableHashTable<TKey, TValue>{
// Required methods
fn length(&self) -> Length;
fn contains<Q>(&self, key: &Q) -> bool
where TKey: Borrow<Q>,
Q: Eq + Hash + ?Sized;
fn get<Q>(&self, key: &Q) -> Option<&TValue>
where TKey: Borrow<Q>,
Q: Eq + Hash + ?Sized;
fn get_key_value<Q>(&self, key: &Q) -> Option<(&TKey, &TValue)>
where TKey: Borrow<Q>,
Q: Eq + Hash + ?Sized;
fn iter<'a>(&'a self) -> impl Iterator<Item = (&'a TKey, &'a TValue)>
where TKey: 'a,
TValue: 'a,
Self: 'a;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Represents an immutable hash table.
Required Methods§
Sourcefn length(&self) -> Length
fn length(&self) -> Length
Returns the number of (TKey, TValue) pairs the table
contains. This typically does not correspond to the actual
size of the table in bytes.
Sourcefn contains<Q>(&self, key: &Q) -> bool
fn contains<Q>(&self, key: &Q) -> bool
Checks if the table contains the corresponding key.
§Notes
The borrowed Q type’s Hash and Eq must match those for TKey.
Sourcefn get<Q>(&self, key: &Q) -> Option<&TValue>
fn get<Q>(&self, key: &Q) -> Option<&TValue>
Checks if the table contains the corresponding key, and if so then returns
the reference to the TValue, or None otherwise.
§Notes
The borrowed Q type’s Hash and Eq must match those for TKey.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<TKey, TValue> ImmutableHashTable<TKey, TValue> for HashMap<TKey, TValue>
Available on crate feature std only.
impl<TKey, TValue> ImmutableHashTable<TKey, TValue> for HashMap<TKey, TValue>
Available on crate feature
std only.