pub struct DebrisPool { /* private fields */ }Expand description
Pre-allocated pool of debris particles. Dead particles are recycled.
Implementations§
Source§impl DebrisPool
impl DebrisPool
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a pool with a specific capacity.
Sourcepub fn spawn(&mut self, particle: DebrisParticle) -> bool
pub fn spawn(&mut self, particle: DebrisParticle) -> bool
Try to spawn a particle. Returns true if there was a free slot.
Sourcepub fn alive_count(&self) -> usize
pub fn alive_count(&self) -> usize
Number of currently alive particles.
Sourcepub fn iter_alive(&self) -> impl Iterator<Item = &DebrisParticle>
pub fn iter_alive(&self) -> impl Iterator<Item = &DebrisParticle>
Iterate over all alive particles (immutable).
Sourcepub fn iter_alive_mut(&mut self) -> impl Iterator<Item = &mut DebrisParticle>
pub fn iter_alive_mut(&mut self) -> impl Iterator<Item = &mut DebrisParticle>
Iterate over all alive particles (mutable).
Sourcepub fn particles(&self) -> &[DebrisParticle]
pub fn particles(&self) -> &[DebrisParticle]
Access the raw particle slice (including dead particles).
Sourcepub fn particles_mut(&mut self) -> &mut [DebrisParticle]
pub fn particles_mut(&mut self) -> &mut [DebrisParticle]
Access the raw particle slice mutably.
Sourcepub fn reclaim_dead(&mut self)
pub fn reclaim_dead(&mut self)
Reclaim dead particles and update the alive count.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DebrisPool
impl RefUnwindSafe for DebrisPool
impl Send for DebrisPool
impl Sync for DebrisPool
impl Unpin for DebrisPool
impl UnsafeUnpin for DebrisPool
impl UnwindSafe for DebrisPool
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.