pub struct Collection<T: HasId> { /* private fields */ }
Expand description
A collection of identifiable entities
This behaves kind of like a HashSet, but only entities’ ids are used Another difference is that it allows for getting mutable references
Implementations§
Source§impl<T: HasId> Collection<T>
impl<T: HasId> Collection<T>
Sourcepub fn get_mut(&mut self, id: &T::Id) -> Option<&mut T>
pub fn get_mut(&mut self, id: &T::Id) -> Option<&mut T>
Get a mutable ref to an entity by its id
Sourcepub fn retain<F: FnMut(&T) -> bool>(&mut self, f: F)
pub fn retain<F: FnMut(&T) -> bool>(&mut self, f: F)
Retain only entities specified by the predicate
Trait Implementations§
Source§impl<T: Clone + HasId> Clone for Collection<T>
impl<T: Clone + HasId> Clone for Collection<T>
Source§fn clone(&self) -> Collection<T>
fn clone(&self) -> Collection<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: HasId> Default for Collection<T>
impl<T: HasId> Default for Collection<T>
Source§impl<'de, T> Deserialize<'de> for Collection<T>where
T: Deserialize<'de> + HasId,
impl<'de, T> Deserialize<'de> for Collection<T>where
T: Deserialize<'de> + HasId,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: HasId> Extend<T> for Collection<T>
impl<T: HasId> Extend<T> for Collection<T>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, entities: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, entities: I)
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
Source§impl<T: HasId> FromIterator<T> for Collection<T>
impl<T: HasId> FromIterator<T> for Collection<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(entities: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(entities: I) -> Self
Creates a value from an iterator. Read more
Source§impl<'a, T: HasId> IntoIterator for &'a Collection<T>
impl<'a, T: HasId> IntoIterator for &'a Collection<T>
Source§impl<'a, T: HasId> IntoIterator for &'a mut Collection<T>
impl<'a, T: HasId> IntoIterator for &'a mut Collection<T>
Source§impl<T: HasId + 'static> IntoIterator for Collection<T>
impl<T: HasId + 'static> IntoIterator for Collection<T>
Source§impl<T> Serialize for Collection<T>
impl<T> Serialize for Collection<T>
impl<T: Eq + HasId> Eq for Collection<T>
impl<T: HasId> StructuralPartialEq for Collection<T>
Auto Trait Implementations§
impl<T> Freeze for Collection<T>
impl<T> RefUnwindSafe for Collection<T>
impl<T> Send for Collection<T>where
T: Send,
impl<T> Sync for Collection<T>where
T: Sync,
impl<T> Unpin for Collection<T>where
T: Unpin,
impl<T> UnwindSafe for Collection<T>
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