Enum implicit_clone::unsync::IMap
source · pub enum IMap<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> {
Static(&'static [(K, V)]),
Rc(Rc<IndexMap<K, V>>),
}
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§
Implementations§
source§impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> IMap<K, V>
sourcepub fn iter(&self) -> IMapIter<'_, K, V> ⓘ
pub fn iter(&self) -> IMapIter<'_, K, V> ⓘ
Return an iterator over the key-value pairs of the map, in their order.
sourcepub fn keys(&self) -> IMapKeys<'_, K, V> ⓘ
pub fn keys(&self) -> IMapKeys<'_, K, V> ⓘ
Return an iterator over the keys of the map, in their order.
sourcepub fn values(&self) -> IMapValues<'_, K, V> ⓘ
pub fn values(&self) -> IMapValues<'_, K, V> ⓘ
Return an iterator over the values of the map, in their order.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the number of key-value pairs in the map.
Computes in O(1) time.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the map contains no elements.
Computes in O(1) time.
sourcepub fn get<Q>(&self, key: &Q) -> Option<V>
pub fn get<Q>(&self, key: &Q) -> Option<V>
Return a clone to the value stored for key
, if it is present,
else None
.
Computes in O(1) time (average).
sourcepub fn get_key_value<Q>(&self, key: &Q) -> Option<(K, V)>
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(K, V)>
Return clones to the key-value pair stored for key
,
if it is present, else None
.
Computes in O(1) time (average).
sourcepub fn get_index(&self, index: usize) -> Option<(K, V)>
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.
sourcepub fn get_index_of<Q>(&self, key: &Q) -> Option<usize>
pub fn get_index_of<Q>(&self, key: &Q) -> Option<usize>
Return item index, if it exists in the map.
Computes in O(1) time (average).
sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Return true
if an equivalent to key
exists in the map.
Computes in O(1) time (average).
Trait Implementations§
source§impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Clone for IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Clone for IMap<K, V>
source§impl<K: Debug + Eq + Hash + ImplicitClone + 'static, V: Debug + PartialEq + ImplicitClone + 'static> Debug for IMap<K, V>
impl<K: Debug + Eq + Hash + ImplicitClone + 'static, V: Debug + PartialEq + ImplicitClone + 'static> Debug for IMap<K, V>
source§impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Default for IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Default for IMap<K, V>
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>,
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>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
source§impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<&'static [(K, V)]> for IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<&'static [(K, V)]> for IMap<K, V>
source§impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<&IMap<K, V>> for IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<&IMap<K, V>> for IMap<K, V>
source§impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<IndexMap<K, V>> for IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<IndexMap<K, V>> for IMap<K, V>
source§impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<Rc<IndexMap<K, V>>> for IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<Rc<IndexMap<K, V>>> for IMap<K, V>
source§impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> FromIterator<(K, V)> for IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> FromIterator<(K, V)> for IMap<K, V>
source§impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> ImplicitClone for IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> ImplicitClone for IMap<K, V>
source§fn implicit_clone(&self) -> Self
fn implicit_clone(&self) -> Self
source§impl<K: PartialEq + Eq + Hash + ImplicitClone + 'static, V: PartialEq + PartialEq + ImplicitClone + 'static> PartialEq for IMap<K, V>
impl<K: PartialEq + Eq + Hash + ImplicitClone + 'static, V: PartialEq + PartialEq + ImplicitClone + 'static> PartialEq for IMap<K, V>
source§impl<K, V> Serialize for IMap<K, V>where
K: Eq + Hash + ImplicitClone + 'static + Serialize,
V: PartialEq + ImplicitClone + 'static + Serialize,
impl<K, V> Serialize for IMap<K, V>where
K: Eq + Hash + ImplicitClone + 'static + Serialize,
V: PartialEq + ImplicitClone + 'static + Serialize,
impl<K: Eq + Eq + Hash + ImplicitClone + 'static, V: Eq + PartialEq + ImplicitClone + 'static> Eq for IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> StructuralPartialEq for IMap<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for IMap<K, V>
impl<K, V> RefUnwindSafe for IMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> !Send for IMap<K, V>
impl<K, V> !Sync for IMap<K, V>
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> 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.