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§
Source§impl<K, V> OrderedMap<K, V>
impl<K, V> OrderedMap<K, V>
Sourcepub fn get_key<T>(&self, key: &T) -> Option<&K>
pub fn get_key<T>(&self, key: &T) -> Option<&K>
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>(&self, key: &T) -> bool
pub fn contains_key<T>(&self, key: &T) -> bool
Determines if key
is in the OrderedMap
.
Sourcepub fn get_index<T>(&self, key: &T) -> Option<usize>
pub fn get_index<T>(&self, key: &T) -> Option<usize>
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>(&self, key: &T) -> Option<(&K, &V)>
pub fn get_entry<T>(&self, key: &T) -> Option<(&K, &V)>
Like get
, but returns both the key and the value.
Sourcepub fn entries(&self) -> Entries<'_, K, V> ⓘ
pub fn entries(&self) -> Entries<'_, K, V> ⓘ
Returns an iterator over the key/value pairs in the map.
Entries are returned in the same order in which they were defined.
Trait Implementations§
Source§impl<K, V> Debug for OrderedMap<K, V>
impl<K, V> Debug for OrderedMap<K, V>
Source§impl<'a, K, V, T> Index<&'a T> for OrderedMap<K, V>
impl<'a, K, V, T> Index<&'a T> for OrderedMap<K, V>
Source§impl<'a, K, V> IntoIterator for &'a OrderedMap<K, V>
impl<'a, K, V> IntoIterator for &'a OrderedMap<K, V>
Source§impl<K, V> PartialEq for OrderedMap<K, V>
impl<K, V> PartialEq for OrderedMap<K, V>
impl<K, V> Eq for OrderedMap<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for OrderedMap<K, V>
impl<K, V> RefUnwindSafe for OrderedMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for OrderedMap<K, V>
impl<K, V> Sync for OrderedMap<K, V>
impl<K, V> Unpin for OrderedMap<K, V>
impl<K, V> UnwindSafe for OrderedMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 56 bytes