Enum implicit_clone::unsync::IMap
source · [−]pub enum IMap<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> {
Static(&'static [(K, V)]),
Rc(Rc<Map<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
Static(&'static [(K, V)])
A (small) static map.
Rc(Rc<Map<K, V>>)
An reference counted map.
Implementations
sourceimpl<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>ⓘNotable traits for IMapIter<'a, K, V>impl<'a, K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Iterator for IMapIter<'a, K, V> type Item = (K, V);
pub fn iter(&self) -> IMapIter<'_, K, V>ⓘNotable traits for IMapIter<'a, K, V>impl<'a, K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Iterator for IMapIter<'a, K, V> type Item = (K, V);
Return an iterator over the key-value pairs of the map, in their order.
sourcepub fn keys(&self) -> IMapKeys<'_, K, V>ⓘNotable traits for IMapKeys<'a, K, V>impl<'a, K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Iterator for IMapKeys<'a, K, V> type Item = K;
pub fn keys(&self) -> IMapKeys<'_, K, V>ⓘNotable traits for IMapKeys<'a, K, V>impl<'a, K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Iterator for IMapKeys<'a, K, V> type Item = K;
Return an iterator over the keys of the map, in their order.
sourcepub fn values(&self) -> IMapValues<'_, K, V>ⓘNotable traits for IMapValues<'a, K, V>impl<'a, K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Iterator for IMapValues<'a, K, V> type Item = V;
pub fn values(&self) -> IMapValues<'_, K, V>ⓘNotable traits for IMapValues<'a, K, V>impl<'a, K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> Iterator for IMapValues<'a, K, V> type Item = 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: ?Sized>(&self, key: &Q) -> Option<V> where
K: Borrow<Q>,
Q: Hash + Eq,
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<V> where
K: Borrow<Q>,
Q: Hash + Eq,
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: ?Sized>(&self, key: &Q) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Hash + Eq,
pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Hash + Eq,
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_full<Q: ?Sized>(&self, key: &Q) -> Option<(usize, K, V)> where
K: Borrow<Q>,
Q: Hash + Eq,
pub fn get_full<Q: ?Sized>(&self, key: &Q) -> Option<(usize, K, V)> where
K: Borrow<Q>,
Q: Hash + Eq,
Return item index, key and value
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: ?Sized>(&self, key: &Q) -> Option<usize> where
K: Borrow<Q>,
Q: Hash + Eq,
pub fn get_index_of<Q: ?Sized>(&self, key: &Q) -> Option<usize> where
K: Borrow<Q>,
Q: Hash + Eq,
Return item index, if it exists in the map.
Computes in O(1) time (average).
Trait Implementations
sourceimpl<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>
sourceimpl<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>
sourceimpl<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>
sourceimpl<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>
sourceimpl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<IndexMap<K, V, RandomState>> for IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<IndexMap<K, V, RandomState>> for IMap<K, V>
sourceimpl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<Rc<IndexMap<K, V, RandomState>>> for IMap<K, V>
impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> From<Rc<IndexMap<K, V, RandomState>>> for IMap<K, V>
sourceimpl<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>
sourcefn from_iter<I: IntoIterator<Item = (K, V)>>(it: I) -> Self
fn from_iter<I: IntoIterator<Item = (K, V)>>(it: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<K: PartialEq + Eq + Hash + ImplicitClone + 'static, V: PartialEq + PartialEq + ImplicitClone + 'static> PartialEq<IMap<K, V>> for IMap<K, V>
impl<K: PartialEq + Eq + Hash + ImplicitClone + 'static, V: PartialEq + PartialEq + ImplicitClone + 'static> PartialEq<IMap<K, V>> for IMap<K, V>
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> 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>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more