pub struct SnapshotStateList<T: Clone + 'static> { /* private fields */ }Expand description
A list whose reads subscribe the current scope and whose writes notify its readers, as Jetpack
Compose’s SnapshotStateList. Clones share the same list.
Implementations§
Source§impl<T: Clone + 'static> SnapshotStateList<T>
impl<T: Clone + 'static> SnapshotStateList<T>
Sourcepub fn with_runtime<I>(values: I, runtime: RuntimeHandle) -> Selfwhere
I: IntoIterator<Item = T>,
pub fn with_runtime<I>(values: I, runtime: RuntimeHandle) -> Selfwhere
I: IntoIterator<Item = T>,
Creates a list holding values in runtime.
Sourcepub fn as_state(&self) -> State<Vec<T>>
pub fn as_state(&self) -> State<Vec<T>>
Returns a read-only view of the state that holds the elements.
Sourcepub fn as_mutable_state(&self) -> MutableState<Vec<T>>
pub fn as_mutable_state(&self) -> MutableState<Vec<T>>
Returns the writable state that holds the elements.
Sourcepub fn iter(&self) -> Vec<T>
pub fn iter(&self) -> Vec<T>
Returns a copy of the elements for iteration. Later writes do not change that copy.
Sourcepub fn get(&self, index: usize) -> T
pub fn get(&self, index: usize) -> T
Returns a copy of the element at index. Panics if index is out of range.
Sourcepub fn get_opt(&self, index: usize) -> Option<T>
pub fn get_opt(&self, index: usize) -> Option<T>
Returns a copy of the element at index, or None if it is out of range.
Sourcepub fn first(&self) -> Option<T>
pub fn first(&self) -> Option<T>
Returns a copy of the first element, or None if the list is empty.
Sourcepub fn last(&self) -> Option<T>
pub fn last(&self) -> Option<T>
Returns a copy of the last element, or None if the list is empty.
Sourcepub fn extend<I>(&self, iter: I)where
I: IntoIterator<Item = T>,
pub fn extend<I>(&self, iter: I)where
I: IntoIterator<Item = T>,
Appends all elements of iter in one write.
Sourcepub fn insert(&self, index: usize, value: T)
pub fn insert(&self, index: usize, value: T)
Inserts value at index, moving later elements back. Panics if index is past the end.
Sourcepub fn set(&self, index: usize, value: T) -> T
pub fn set(&self, index: usize, value: T) -> T
Replaces the element at index and returns the old one. Panics if index is out of range.
Sourcepub fn remove(&self, index: usize) -> T
pub fn remove(&self, index: usize) -> T
Removes and returns the element at index. Panics if index is out of range.
Sourcepub fn pop(&self) -> Option<T>
pub fn pop(&self) -> Option<T>
Removes and returns the last element, or None if the list is empty.
Sourcepub fn replace_with<I>(&self, iter: I)where
I: IntoIterator<Item = T>,
pub fn replace_with<I>(&self, iter: I)where
I: IntoIterator<Item = T>,
Replaces all elements with those of iter in one write.