pub struct OrderedMap<K: 'static, V: 'static> { /* private fields */ }
Expand description
An order-preserving map which can be constructed at compile time.
“Order-preserving” means iteration order is guaranteed to match the definition order.
Implementations§
Source§impl<K, V> OrderedMap<K, V>
impl<K, V> OrderedMap<K, V>
Sourcepub fn get<T: ?Sized>(&self, key: &T) -> Option<&V>where
K: PhfKeyProxy<T>,
pub fn get<T: ?Sized>(&self, key: &T) -> Option<&V>where
K: PhfKeyProxy<T>,
Returns a reference to the value that key
maps to.
Examples found in repository?
More examples
Sourcepub fn get_key<T: ?Sized>(&self, key: &T) -> Option<&K>where
K: PhfKeyProxy<T>,
pub fn get_key<T: ?Sized>(&self, key: &T) -> Option<&K>where
K: PhfKeyProxy<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
K: PhfKeyProxy<T>,
pub fn contains_key<T: ?Sized>(&self, key: &T) -> boolwhere
K: PhfKeyProxy<T>,
Determines if key
is in the OrderedMap
.
Sourcepub fn get_index<T: ?Sized>(&self, key: &T) -> Option<usize>where
K: PhfKeyProxy<T>,
pub fn get_index<T: ?Sized>(&self, key: &T) -> Option<usize>where
K: PhfKeyProxy<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
K: PhfKeyProxy<T>,
pub fn get_entry<T: ?Sized>(&self, key: &T) -> Option<(&K, &V)>where
K: PhfKeyProxy<T>,
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<K, V> Default for OrderedMap<K, V>
impl<K, V> Default for OrderedMap<K, V>
Source§impl<'a, K, V, T: ?Sized> Index<&'a T> for OrderedMap<K, V>where
K: PhfKeyProxy<T>,
impl<'a, K, V, T: ?Sized> Index<&'a T> for OrderedMap<K, V>where
K: PhfKeyProxy<T>,
Source§impl<'a, K, V> IntoIterator for &'a OrderedMap<K, V>
impl<'a, K, V> IntoIterator for &'a OrderedMap<K, V>
impl<K: Eq, V: Eq> 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
Mutably borrows from an owned value. Read more