pub struct Collection<In, Ix> { /* 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>where
Ix: Index<In>,
impl<In, Ix> Collection<In, Ix>where
Ix: Index<In>,
Sourcepub fn new(ix: Ix) -> Collection<In, Ix>
pub fn new(ix: Ix) -> Collection<In, Ix>
Create an empty collection.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&Key, &In)>
pub fn iter(&self) -> impl Iterator<Item = (&Key, &In)>
Iterate over all items in the collection.
Sourcepub fn update_mut<F>(&mut self, key: Key, f: F)
pub fn update_mut<F>(&mut self, key: Key, f: F)
Mutate (or alter the presence of) the item in the collection.
Sourcepub fn adjust_mut<F>(&mut self, key: Key, f: F)
pub fn adjust_mut<F>(&mut self, key: Key, f: F)
Mutate the item in the collection, if it exists.
Sourcepub fn delete(&mut self, key: &Key) -> Option<In>
pub fn delete(&mut self, key: &Key) -> Option<In>
Remove an item from the collection, returning it if it exists.
Sourcepub fn query(&self) -> <Ix as Index<In>>::Query<'_, In>
pub fn query(&self) -> <Ix as Index<In>>::Query<'_, In>
Query the collection using its index(es).
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl<In, Ix> Freeze for Collection<In, Ix>where
Ix: Freeze,
impl<In, Ix> RefUnwindSafe for Collection<In, Ix>where
Ix: RefUnwindSafe,
In: RefUnwindSafe,
impl<In, Ix> Send for Collection<In, Ix>
impl<In, Ix> Sync for Collection<In, Ix>
impl<In, Ix> Unpin for Collection<In, Ix>
impl<In, Ix> UnwindSafe for Collection<In, Ix>where
Ix: UnwindSafe,
In: UnwindSafe,
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