pub struct EntityList<T, Ref: EntityRef> { /* private fields */ }
Expand description
A list of entities.
This implementation is essentially a glorified Vec<T>
, which returns a Ref
when pushed to. Of course, since it is indexed by EntityRef
s, it can only index
u32::MAX
items. It can hold more items than this (if there is enough space in memory), but the items past the limit will be un-indexable by EntityRef
s.
Implementations§
Source§impl<T, Ref: EntityRef> EntityList<T, Ref>
impl<T, Ref: EntityRef> EntityList<T, Ref>
Sourcepub fn push(&mut self, item: T) -> Ref
pub fn push(&mut self, item: T) -> Ref
Pushes an item onto the end of the entity list, and returns a reference to it.
Sourcepub fn get(&self, item: Ref) -> &T
pub fn get(&self, item: Ref) -> &T
Returns the item associated with the given reference. Will panic if item
is an invalid reference, or out of bounds.
Sourcepub fn get_mut(&mut self, item: Ref) -> &mut T
pub fn get_mut(&mut self, item: Ref) -> &mut T
Returns a mutable reference to the provided item.
Sourcepub fn entities(&self) -> &Vec<T>
pub fn entities(&self) -> &Vec<T>
Returns the entities which are currently stored in this entity list.
Sourcepub fn entities_mut(&mut self) -> &mut Vec<T>
pub fn entities_mut(&mut self) -> &mut Vec<T>
Returns a mutable reference to the entities which are stored in this entity list.
Trait Implementations§
Source§impl<T: Clone, Ref: Clone + EntityRef> Clone for EntityList<T, Ref>
impl<T: Clone, Ref: Clone + EntityRef> Clone for EntityList<T, Ref>
Source§fn clone(&self) -> EntityList<T, Ref>
fn clone(&self) -> EntityList<T, Ref>
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 moreimpl<T, Ref: EntityRef> StructuralPartialEq for EntityList<T, Ref>
Auto Trait Implementations§
impl<T, Ref> Freeze for EntityList<T, Ref>
impl<T, Ref> RefUnwindSafe for EntityList<T, Ref>where
Ref: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, Ref> Send for EntityList<T, Ref>
impl<T, Ref> Sync for EntityList<T, Ref>
impl<T, Ref> Unpin for EntityList<T, Ref>
impl<T, Ref> UnwindSafe for EntityList<T, Ref>where
Ref: UnwindSafe,
T: 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