pub struct EntityAllocator { /* private fields */ }Expand description
Allocates and manages entity IDs and generations, allowing safe reuse of entity IDs.
§Fields
generations: Per-id generation counters used to validate entity liveness.free_ids: Pool of reusable entity IDs.
§Safety
- Reuse safety is enforced by bumping the generation on destroy, invalidating
stale
Entityvalues that refer to the sameidwith an older generation.
Implementations§
Source§impl EntityAllocator
impl EntityAllocator
Sourcepub fn create(&mut self) -> Entity
pub fn create(&mut self) -> Entity
Creates a new entity, reusing an ID if possible, otherwise assigning a new one.
§Returns
Entity: The newly allocated entity identifier (with current generation for its id).
Trait Implementations§
Source§impl Default for EntityAllocator
impl Default for EntityAllocator
Source§fn default() -> EntityAllocator
fn default() -> EntityAllocator
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for EntityAllocator
impl RefUnwindSafe for EntityAllocator
impl Send for EntityAllocator
impl Sync for EntityAllocator
impl Unpin for EntityAllocator
impl UnwindSafe for EntityAllocator
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