OrderedMap

Struct OrderedMap 

Source
pub struct OrderedMap<K: 'static, V: 'static>(/* private fields */);
Expand description

An order-preserving immutable map with lookup via a perfect hash function.

Constructable at compile time with a BuildOrderedMap. Unlike a Map, iteration order is guaranteed to match the definition order.

Internally, this is a wrapper for phf::OrderedMap from the excellent phf crate.

This API requires the following crate feature to be activated: map

Implementations§

Source§

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

Source

pub const fn len(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn entries(&self) -> Entries<'_, K, V>

Source

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

Source

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

Source

pub const fn init_raw(map: OrderedMap<K, V>) -> OrderedMap<K, V>

An implementation detail. You shouldn’t need to call this function.

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>,

Source§

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>,

Source§

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.