pub struct SnapshotStateMap<K, V>{ /* private fields */ }Expand description
A hash map whose reads subscribe the current scope and whose writes notify its readers, as
Jetpack Compose’s SnapshotStateMap. Clones share the same map.
Implementations§
Source§impl<K, V> SnapshotStateMap<K, V>
impl<K, V> SnapshotStateMap<K, V>
Sourcepub fn with_runtime<I>(pairs: I, runtime: RuntimeHandle) -> Selfwhere
I: IntoIterator<Item = (K, V)>,
pub fn with_runtime<I>(pairs: I, runtime: RuntimeHandle) -> Selfwhere
I: IntoIterator<Item = (K, V)>,
Creates a map holding pairs in runtime.
Sourcepub fn as_state(&self) -> State<HashMap<K, V>>
pub fn as_state(&self) -> State<HashMap<K, V>>
Returns a read-only view of the state that holds the map.
Sourcepub fn as_mutable_state(&self) -> MutableState<HashMap<K, V>>
pub fn as_mutable_state(&self) -> MutableState<HashMap<K, V>>
Returns the writable state that holds the map.
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Returns true if the map has an entry for key.
Sourcepub fn get(&self, key: &K) -> Option<V>
pub fn get(&self, key: &K) -> Option<V>
Returns a copy of the value under key, or None if there is none.
Sourcepub fn to_hash_map(&self) -> HashMap<K, V>
pub fn to_hash_map(&self) -> HashMap<K, V>
Returns a copy of the whole map.
Sourcepub fn insert(&self, key: K, value: V) -> Option<V>
pub fn insert(&self, key: K, value: V) -> Option<V>
Stores value under key and returns the value it replaced, if any.
Sourcepub fn extend<I>(&self, iter: I)where
I: IntoIterator<Item = (K, V)>,
pub fn extend<I>(&self, iter: I)where
I: IntoIterator<Item = (K, V)>,
Inserts all pairs from iter in one write, replacing the values of keys already present.
Trait Implementations§
Source§impl<K, V> Clone for SnapshotStateMap<K, V>
impl<K, V> Clone for SnapshotStateMap<K, V>
Auto Trait Implementations§
impl<K, V> !RefUnwindSafe for SnapshotStateMap<K, V>
impl<K, V> !Send for SnapshotStateMap<K, V>
impl<K, V> !Sync for SnapshotStateMap<K, V>
impl<K, V> !UnwindSafe for SnapshotStateMap<K, V>
impl<K, V> Freeze for SnapshotStateMap<K, V>
impl<K, V> Unpin for SnapshotStateMap<K, V>
impl<K, V> UnsafeUnpin for SnapshotStateMap<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