pub struct SharedMap<K, V>(/* private fields */);Expand description
A shared mutable hash map managed by reference counting.
§Cloning
The Clone trait implements cloning of the map by reference.
Use the clone_content() method to clone the map by content.
§Equality
The PartialEq trait performs reference comparison of two maps.
§Hashing
The Hash trait performs hashing of the map by reference.
§Iteration
To iterate a SharedMap, it is required to invoke the borrow() method,
as in the following snippet:
ⓘ
for (k, v) in map_object.borrow().iter() {
// k: &K
// v: &V
}Implementations§
pub fn new() -> Self
pub fn get(&self, key: &K) -> Option<V>
pub fn set(&mut self, key: K, value: V)
pub fn remove(&mut self, key: &K) -> Option<V>
pub fn clear(&mut self)
pub fn has(&self, key: &K) -> bool
pub fn length(&self) -> usize
pub fn clone_content(&self) -> Self
pub fn borrow(&self) -> Ref<'_, HashMap<K, V>>
pub fn borrow_mut(&mut self) -> RefMut<'_, HashMap<K, V>>
Trait Implementations§
Source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Auto Trait Implementations§
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