[][src]Struct phf::OrderedMap

pub struct OrderedMap<K: 'static, V: 'static> { /* fields omitted */ }

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

impl<K, V> OrderedMap<K, V>[src]

pub fn len(&self) -> usize[src]

Returns the number of entries in the Map.

pub fn is_empty(&self) -> bool[src]

Returns true if the Map is empty.

pub fn get<T: ?Sized>(&self, key: &T) -> Option<&V> where
    T: Eq + PhfHash,
    K: PhfBorrow<T>, 
[src]

Returns a reference to the value that key maps to.

pub fn get_key<T: ?Sized>(&self, key: &T) -> Option<&K> where
    T: Eq + PhfHash,
    K: PhfBorrow<T>, 
[src]

Returns a reference to the map's internal static instance of the given key.

This can be useful for interning schemes.

pub fn contains_key<T: ?Sized>(&self, key: &T) -> bool where
    T: Eq + PhfHash,
    K: PhfBorrow<T>, 
[src]

Determines if key is in the Map.

pub fn get_index<T: ?Sized>(&self, key: &T) -> Option<usize> where
    T: Eq + PhfHash,
    K: PhfBorrow<T>, 
[src]

Returns the index of the key within the list used to initialize the ordered map.

pub fn index(&self, index: usize) -> Option<(&K, &V)>[src]

Returns references to both the key and values at an index within the list used to initialize the ordered map. See .get_index(key).

pub fn get_entry<T: ?Sized>(&self, key: &T) -> Option<(&K, &V)> where
    T: Eq + PhfHash,
    K: PhfBorrow<T>, 
[src]

Like get, but returns both the key and the value.

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);
[src]

Returns an iterator over the key/value pairs in the map.

Entries are returned in the same order in which they were defined.

pub fn keys(&self) -> Keys<'_, K, V>

Notable traits for Keys<'a, K, V>

impl<'a, K, V> Iterator for Keys<'a, K, V> type Item = &'a K;
[src]

Returns an iterator over the keys in the map.

Keys are returned in the same order in which they were defined.

pub fn values(&self) -> Values<'_, K, V>

Notable traits for Values<'a, K, V>

impl<'a, K, V> Iterator for Values<'a, K, V> type Item = &'a V;
[src]

Returns an iterator over the values in the map.

Values are returned in the same order in which they were defined.

Trait Implementations

impl<K, V> Debug for OrderedMap<K, V> where
    K: Debug,
    V: Debug
[src]

impl<'a, K, V, T: ?Sized> Index<&'a T> for OrderedMap<K, V> where
    T: Eq + PhfHash,
    K: PhfBorrow<T>, 
[src]

type Output = V

The returned type after indexing.

impl<'a, K, V> IntoIterator for &'a OrderedMap<K, V>[src]

type Item = (&'a K, &'a V)

The type of the elements being iterated over.

type IntoIter = Entries<'a, K, V>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<K, V> RefUnwindSafe for OrderedMap<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V> Send for OrderedMap<K, V> where
    K: Send + Sync,
    V: Send + Sync

impl<K, V> Sync for OrderedMap<K, V> where
    K: Sync,
    V: Sync

impl<K, V> Unpin for OrderedMap<K, V> where
    K: Unpin,
    V: Unpin

impl<K, V> UnwindSafe for OrderedMap<K, V> where
    K: RefUnwindSafe + UnwindSafe,
    V: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.