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§

source§

impl<K, V> OrderedMap<K, V>

source

pub const fn len(&self) -> usize

Returns the number of entries in the OrderedMap.

source

pub const fn is_empty(&self) -> bool

Returns true if the OrderedMap is empty.

source

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

Returns a reference to the value that key maps to.

source

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

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

This can be useful for interning schemes.

source

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

Determines if key is in the OrderedMap.

source

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

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

source

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).

source

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

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

source

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.

source

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

Returns an iterator over the keys in the map.

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

source

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

Returns an iterator over the values in the map.

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

Trait Implementations§

source§

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

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

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

§

type Output = V

The returned type after indexing.
source§

fn index(&self, k: &'a T) -> &V

Performs the indexing (container[index]) operation. Read more
source§

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

§

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?
source§

fn into_iter(self) -> Entries<'a, K, V>

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<K, V> Freeze for OrderedMap<K, V>

§

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

§

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

§

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

§

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

§

impl<K, V> UnwindSafe for OrderedMap<K, V>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.