Struct phf::OrderedMap
source · [−]pub struct OrderedMap<K: 'static, V: 'static> { /* private fields */ }
Expand description
An order-preserving immutable map constructed at compile time.
Unlike a Map
, iteration order is guaranteed to match the definition
order.
Note
The fields of this struct are public so that they may be initialized by the
phf_ordered_map!
macro and code generation. They are subject to change at
any time and should never be accessed directly.
Implementations
sourceimpl<K, V> OrderedMap<K, V>
impl<K, V> OrderedMap<K, V>
sourcepub fn get<T: ?Sized>(&self, key: &T) -> Option<&V>where
T: Eq + PhfHash,
K: PhfBorrow<T>,
pub fn get<T: ?Sized>(&self, key: &T) -> Option<&V>where
T: Eq + PhfHash,
K: PhfBorrow<T>,
Returns a reference to the value that key
maps to.
sourcepub fn get_key<T: ?Sized>(&self, key: &T) -> Option<&K>where
T: Eq + PhfHash,
K: PhfBorrow<T>,
pub fn get_key<T: ?Sized>(&self, key: &T) -> Option<&K>where
T: Eq + PhfHash,
K: PhfBorrow<T>,
Returns a reference to the map’s internal static instance of the given key.
This can be useful for interning schemes.
sourcepub fn contains_key<T: ?Sized>(&self, key: &T) -> boolwhere
T: Eq + PhfHash,
K: PhfBorrow<T>,
pub fn contains_key<T: ?Sized>(&self, key: &T) -> boolwhere
T: Eq + PhfHash,
K: PhfBorrow<T>,
Determines if key
is in the OrderedMap
.
sourcepub fn get_index<T: ?Sized>(&self, key: &T) -> Option<usize>where
T: Eq + PhfHash,
K: PhfBorrow<T>,
pub fn get_index<T: ?Sized>(&self, key: &T) -> Option<usize>where
T: Eq + PhfHash,
K: PhfBorrow<T>,
Returns the index of the key within the list used to initialize the ordered map.
sourcepub fn index(&self, index: usize) -> Option<(&K, &V)>
pub fn index(&self, index: usize) -> Option<(&K, &V)>
Returns references to both the key and values at an index
within the list used to initialize the ordered map. See .get_index(key)
.
sourcepub fn get_entry<T: ?Sized>(&self, key: &T) -> Option<(&K, &V)>where
T: Eq + PhfHash,
K: PhfBorrow<T>,
pub fn get_entry<T: ?Sized>(&self, key: &T) -> Option<(&K, &V)>where
T: Eq + PhfHash,
K: PhfBorrow<T>,
Like get
, but returns both the key and the value.
sourcepub fn entries(&self) -> Entries<'_, K, V>ⓘNotable traits for Entries<'a, K, V>impl<'a, K, V> Iterator for Entries<'a, K, V> type Item = (&'a K, &'a V);
pub fn entries(&self) -> Entries<'_, K, V>ⓘNotable traits for Entries<'a, K, V>impl<'a, K, V> Iterator for Entries<'a, K, V> type Item = (&'a K, &'a V);
Returns an iterator over the key/value pairs in the map.
Entries are returned in the same order in which they were defined.