Struct ref_kind::RefKindMap
source · [−]#[repr(transparent)]pub struct RefKindMap<'a, K, V, S = RandomState> where
V: ?Sized + 'a, { /* private fields */ }Expand description
Hash map for different kinds of reference.
This type provides methods for retrieving references (either immutable or mutable) by moving them out of the map to preserve specified lifetime of the owner.
Implementations
sourceimpl<'a, K, V, S> RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: BuildHasher,
impl<'a, K, V, S> RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: BuildHasher,
sourcepub fn get_ref(&self, key: &K) -> Option<&V>
pub fn get_ref(&self, key: &K) -> Option<&V>
Returns an immutable reference of the value without preserving lifetime of the owner.
Panics
Panics if mutable reference of the value was already moved out of the map.
sourcepub fn get_mut(&mut self, key: &K) -> Option<&mut V>
pub fn get_mut(&mut self, key: &K) -> Option<&mut V>
Returns a mutable reference of the value without preserving lifetime of the owner.
Panics
Panics if mutable reference of the value was already moved out of the map or the value was already borrowed as immutable.
sourcepub fn move_ref(&mut self, key: K) -> Option<&'a V>
pub fn move_ref(&mut self, key: K) -> Option<&'a V>
Moves an immutable reference of the value out of this map.
This function copies an immutable reference or replaces mutable reference with immutable one, preserving an immutable reference in this map.
Panics
Panics if mutable reference of the value was already moved out of the map.
Trait Implementations
sourceimpl<'a, K, V, S> Default for RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: Default,
impl<'a, K, V, S> Default for RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: Default,
sourceimpl<'a, K, V, S> Extend<(K, &'a V)> for RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: BuildHasher,
impl<'a, K, V, S> Extend<(K, &'a V)> for RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: BuildHasher,
sourcefn extend<T: IntoIterator<Item = (K, &'a V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, &'a V)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<'a, K, V, S> Extend<(K, &'a mut V)> for RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: BuildHasher,
impl<'a, K, V, S> Extend<(K, &'a mut V)> for RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: BuildHasher,
sourcefn extend<T: IntoIterator<Item = (K, &'a mut V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, &'a mut V)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<'a, K, V, S> FromIterator<(K, &'a V)> for RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: BuildHasher + Default,
impl<'a, K, V, S> FromIterator<(K, &'a V)> for RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: BuildHasher + Default,
sourcefn from_iter<T: IntoIterator<Item = (K, &'a V)>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = (K, &'a V)>>(iter: T) -> Self
Creates a value from an iterator. Read more
sourceimpl<'a, K, V, S> FromIterator<(K, &'a mut V)> for RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: BuildHasher + Default,
impl<'a, K, V, S> FromIterator<(K, &'a mut V)> for RefKindMap<'a, K, V, S> where
K: Eq + Hash,
V: ?Sized + 'a,
S: BuildHasher + Default,
sourcefn from_iter<T: IntoIterator<Item = (K, &'a mut V)>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = (K, &'a mut V)>>(iter: T) -> Self
Creates a value from an iterator. Read more
Auto Trait Implementations
impl<'a, K, V: ?Sized, S> RefUnwindSafe for RefKindMap<'a, K, V, S> where
K: RefUnwindSafe,
S: RefUnwindSafe,
V: RefUnwindSafe,
impl<'a, K, V: ?Sized, S> Send for RefKindMap<'a, K, V, S> where
K: Send,
S: Send,
V: Send + Sync,
impl<'a, K, V: ?Sized, S> Sync for RefKindMap<'a, K, V, S> where
K: Sync,
S: Sync,
V: Sync,
impl<'a, K, V: ?Sized, S> Unpin for RefKindMap<'a, K, V, S> where
K: Unpin,
S: Unpin,
impl<'a, K, V, S = RandomState> !UnwindSafe for RefKindMap<'a, K, V, S>
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