pub struct Collection<In, Ix, S = DefaultStore<In>> { /* private fields */ }Expand description
A collection of items, with an index that is automatically kept up-to-date.
Implementations§
Source§impl<In, Ix> Collection<In, Ix>
impl<In, Ix> Collection<In, Ix>
Source§impl<In, Ix, S: Default> Collection<In, Ix, S>
impl<In, Ix, S: Default> Collection<In, Ix, S>
Sourcepub fn new_with_empty_store(ix: Ix) -> Self
pub fn new_with_empty_store(ix: Ix) -> Self
Create an empty collection.
Source§impl<In, Ix, S> Collection<In, Ix, S>
impl<In, Ix, S> Collection<In, Ix, S>
Sourcepub fn new_with_store(store: S, ix: Ix) -> Self
pub fn new_with_store(store: S, ix: Ix) -> Self
Create an empty collection with a custom store.
Source§impl<In, Ix, S> Collection<In, Ix, S>
impl<In, Ix, S> Collection<In, Ix, S>
Sourcepub fn get_by_key(&self, key: Key) -> Option<&In>
pub fn get_by_key(&self, key: Key) -> Option<&In>
Lookup an item in the collection by its key.
Sourcepub fn iter(&self) -> impl IntoIterator<Item = (Key, &In)>
pub fn iter(&self) -> impl IntoIterator<Item = (Key, &In)>
Iterate over all items in the collection.
Sourcepub fn update_by_key_mut<F>(&mut self, key: Key, f: F)
pub fn update_by_key_mut<F>(&mut self, key: Key, f: F)
Mutate (or alter the presence of) the item in the collection.
Sourcepub fn update_by_key<F>(&mut self, key: Key, f: F)
pub fn update_by_key<F>(&mut self, key: Key, f: F)
Update the item in the collection.
Sourcepub fn adjust_by_key_mut<F>(&mut self, key: Key, f: F)
pub fn adjust_by_key_mut<F>(&mut self, key: Key, f: F)
Mutate the item in the collection, if it exists.
Sourcepub fn adjust_by_key<F>(&mut self, key: Key, f: F)
pub fn adjust_by_key<F>(&mut self, key: Key, f: F)
Adjust the item in the collection, if it exists.
Sourcepub fn delete_by_key(&mut self, key: Key) -> Option<In>
pub fn delete_by_key(&mut self, key: Key) -> Option<In>
Remove an item from the collection, returning it if it exists.
Sourcepub fn query<Res>(&self, f: impl FnOnce(&Ix) -> Res) -> Res::Resolved<&In>where
Res: QueryResult,
pub fn query<Res>(&self, f: impl FnOnce(&Ix) -> Res) -> Res::Resolved<&In>where
Res: QueryResult,
Query the collection using its index(es).