pub enum IMap<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> {
    Static(&'static [(K, V)]),
    Rc(Arc<IndexMap<K, V>>),
}
Available on crate feature map only.
Expand description

An immutable hash map type inspired by Immutable.js.

This type is cheap to clone and thus implements ImplicitClone. It can be created based on a &'static [(K, V)], or based on a reference counted IndexMap.

This type has the least stable API at the moment and is subject to change a lot before the 1.0 release.

Variants§

§

Static(&'static [(K, V)])

A (small) static map.

§

Rc(Arc<IndexMap<K, V>>)

An reference counted map.

Implementations§

source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> IMap<K, V>

source

pub fn iter(&self) -> IMapIter<'_, K, V>

Return an iterator over the key-value pairs of the map, in their order.

source

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

Return an iterator over the keys of the map, in their order.

source

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

Return an iterator over the values of the map, in their order.

source

pub fn len(&self) -> usize

Return the number of key-value pairs in the map.

Computes in O(1) time.

source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

Computes in O(1) time.

source

pub fn get<Q>(&self, key: &Q) -> Option<V>where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Return a clone to the value stored for key, if it is present, else None.

Computes in O(1) time (average).

source

pub fn get_key_value<Q>(&self, key: &Q) -> Option<(K, V)>where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Return clones to the key-value pair stored for key, if it is present, else None.

Computes in O(1) time (average).

source

pub fn get_full<Q>(&self, key: &Q) -> Option<(usize, K, V)>where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Return item index, key and value

source

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

Get a key-value pair by index.

Valid indices are 0 <= index < self.len()

Computes in O(1) time.

source

pub fn get_index_of<Q>(&self, key: &Q) -> Option<usize>where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Return item index, if it exists in the map.

Computes in O(1) time (average).

source

pub fn contains_key<Q>(&self, key: &Q) -> boolwhere K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Return true if an equivalent to key exists in the map.

Computes in O(1) time (average).

source

pub fn last(&self) -> Option<(K, V)>

Get the last key-value pair.

Computes in O(1) time.

Trait Implementations§

source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Clone for IMap<K, V>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<K: Debug + Eq + Hash + ImplicitClone + 'static, V: Debug + PartialEq + ImplicitClone + 'static> Debug for IMap<K, V>

source§

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

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

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Default for IMap<K, V>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, K, V> Deserialize<'de> for IMap<K, V>where K: Eq + Hash + ImplicitClone + 'static + Deserialize<'de>, V: PartialEq + ImplicitClone + 'static + Deserialize<'de>,

source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<&'static [(K, V)]> for IMap<K, V>

source§

fn from(a: &'static [(K, V)]) -> IMap<K, V>

Converts to this type from the input type.
source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<&IMap<K, V>> for IMap<K, V>

source§

fn from(a: &IMap<K, V>) -> IMap<K, V>

Converts to this type from the input type.
source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<Arc<IndexMap<K, V>>> for IMap<K, V>

source§

fn from(a: Rc<Map<K, V>>) -> IMap<K, V>

Converts to this type from the input type.
source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<IndexMap<K, V>> for IMap<K, V>

source§

fn from(a: Map<K, V>) -> IMap<K, V>

Converts to this type from the input type.
source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> FromIterator<(K, V)> for IMap<K, V>

source§

fn from_iter<I: IntoIterator<Item = (K, V)>>(it: I) -> Self

Creates a value from an iterator. Read more
source§

impl<K: PartialEq + Eq + Hash + ImplicitClone + 'static, V: PartialEq + PartialEq + ImplicitClone + 'static> PartialEq for IMap<K, V>

source§

fn eq(&self, other: &IMap<K, V>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, V> Serialize for IMap<K, V>where K: Eq + Hash + ImplicitClone + 'static + Serialize, V: PartialEq + ImplicitClone + 'static + Serialize,

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl<K: Eq + Eq + Hash + ImplicitClone + 'static, V: Eq + PartialEq + ImplicitClone + 'static> Eq for IMap<K, V>

source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> ImplicitClone for IMap<K, V>

source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> StructuralEq for IMap<K, V>

source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> StructuralPartialEq for IMap<K, V>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<K, V> UnwindSafe for IMap<K, V>where K: RefUnwindSafe, V: RefUnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,