pub struct Map<K: 'static + Key, V: 'static + Value>(/* private fields */);
Expand description
Multithreaded hash map that is always saved atomically
Calling clone()
will create a reference to the
same instance, and can be easily shared between threads.
For tracking incremental changes to your data structure, look at
VersionedMap
Implementations§
Source§impl<K, V> Map<K, V>
impl<K, V> Map<K, V>
Sourcepub fn insert(&self, key: K, value: impl Into<Arc<V>>) -> Arc<V>
pub fn insert(&self, key: K, value: impl Into<Arc<V>>) -> Arc<V>
Insert a new value for the given key in the map.
Sourcepub fn update_with<Q, R>(
&self,
key: &Q,
fun: impl FnOnce(&K, &mut Arc<V>) -> R,
) -> Option<R>
pub fn update_with<Q, R>( &self, key: &Q, fun: impl FnOnce(&K, &mut Arc<V>) -> R, ) -> Option<R>
Update a value with the given key, and return the new value if the key exists.
Sourcepub fn insert_with(&self, key: K, fun: impl FnMut() -> V) -> Arc<V>
pub fn insert_with(&self, key: K, fun: impl FnMut() -> V) -> Arc<V>
Call the given function to insert a value if it doesn’t exist. Return with the current value to the key.
Sourcepub fn contains<Q>(&self, key: &Q) -> bool
pub fn contains<Q>(&self, key: &Q) -> bool
Returns if there’s an addition for the specified key.
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for Map<K, V>
impl<K, V> RefUnwindSafe for Map<K, V>
impl<K, V> Send for Map<K, V>
impl<K, V> Sync for Map<K, V>
impl<K, V> Unpin for Map<K, V>
impl<K, V> UnwindSafe for Map<K, V>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)