Trait shipyard::IntoFastIter[][src]

pub trait IntoFastIter {
    type IntoIter: Iterator;
    type IntoParIter;
    fn fast_iter(self) -> Self::IntoIter;
fn fast_iter_by<D: 'static>(self) -> Self::IntoIter;
fn fast_par_iter(self) -> Self::IntoParIter; }

Trait used to create iterators.
Yields &mut T for mutable components. Does not work with storage tracking modification.

std::iter::IntoIterator can’t be used directly because of conflicting implementation.
This trait serves as substitute.

Associated Types

Loading content...

Required methods

fn fast_iter(self) -> Self::IntoIter[src]

Returns an iterator over SparseSet.
Panics if one of the storage is tracking modification.
You can check if a SparseSet is tracking modification with SparseSet::is_tracking_modification.

iter can be used for storage tracking modification.

Example

use shipyard::{EntitiesViewMut, IntoFastIter, ViewMut, World};

let world = World::new();

let (mut entities, mut usizes, mut u32s) = world.borrow::<(EntitiesViewMut, ViewMut<usize>, ViewMut<u32>)>().unwrap();

entities.add_entity((&mut usizes, &mut u32s), (0usize, 1u32));
entities.add_entity((&mut usizes, &mut u32s), (2usize, 3u32));

(&mut usizes, &u32s).fast_iter().for_each(|(x, &y)| {
    *x += y as usize;
});

fn fast_iter_by<D: 'static>(self) -> Self::IntoIter[src]

Returns an iterator over SparseSet, its order is based on D.
Panics if one of the storage is tracking modification.
You can check if a SparseSet is tracking modification with SparseSet::is_tracking_modification.

iter_by can be used for storage tracking modification.

fn fast_par_iter(self) -> Self::IntoParIter[src]

Returns a parallel iterator over SparseSet.
Panics if one of the storage is tracking modification.
You can check if a SparseSet is tracking modification with SparseSet::is_tracking_modification.

par_iter can be used for storage tracking modification.

Example

use rayon::prelude::ParallelIterator;
use shipyard::{EntitiesViewMut, IntoFastIter, ViewMut, World};

let world = World::new();

let (mut entities, mut usizes, mut u32s) = world.borrow::<(EntitiesViewMut, ViewMut<usize>, ViewMut<u32>)>().unwrap();

entities.add_entity((&mut usizes, &mut u32s), (0usize, 1u32));
entities.add_entity((&mut usizes, &mut u32s), (2usize, 3u32));

(&mut usizes, &u32s).fast_par_iter().for_each(|(x, &y)| {
    *x += y as usize;
});
Loading content...

Implementations on Foreign Types

impl<T: IntoAbstract> IntoFastIter for (T,) where
    T::AbsView: FastAbstractMut,
    <T::AbsView as AbstractMut>::Index: From<usize> + Clone
[src]

type IntoIter = FastIter<(T::AbsView,)>

type IntoParIter = FastParIter<(T::AbsView,)>

impl<A: IntoAbstract, B: IntoAbstract> IntoFastIter for (A, B) where
    A::AbsView: FastAbstractMut,
    B::AbsView: FastAbstractMut,
    <A::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <B::AbsView as AbstractMut>::Index: From<usize> + Clone
[src]

type IntoIter = FastIter<(A::AbsView, B::AbsView)>

type IntoParIter = FastParIter<(A::AbsView, B::AbsView)>

impl<A: IntoAbstract, B: IntoAbstract, C: IntoAbstract> IntoFastIter for (A, B, C) where
    A::AbsView: FastAbstractMut,
    B::AbsView: FastAbstractMut,
    C::AbsView: FastAbstractMut,
    <A::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <B::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <C::AbsView as AbstractMut>::Index: From<usize> + Clone
[src]

type IntoIter = FastIter<(A::AbsView, B::AbsView, C::AbsView)>

type IntoParIter = FastParIter<(A::AbsView, B::AbsView, C::AbsView)>

impl<A: IntoAbstract, B: IntoAbstract, C: IntoAbstract, D: IntoAbstract> IntoFastIter for (A, B, C, D) where
    A::AbsView: FastAbstractMut,
    B::AbsView: FastAbstractMut,
    C::AbsView: FastAbstractMut,
    D::AbsView: FastAbstractMut,
    <A::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <B::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <C::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <D::AbsView as AbstractMut>::Index: From<usize> + Clone
[src]

type IntoIter = FastIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView)>

type IntoParIter = FastParIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView)>

impl<A: IntoAbstract, B: IntoAbstract, C: IntoAbstract, D: IntoAbstract, E: IntoAbstract> IntoFastIter for (A, B, C, D, E) where
    A::AbsView: FastAbstractMut,
    B::AbsView: FastAbstractMut,
    C::AbsView: FastAbstractMut,
    D::AbsView: FastAbstractMut,
    E::AbsView: FastAbstractMut,
    <A::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <B::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <C::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <D::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <E::AbsView as AbstractMut>::Index: From<usize> + Clone
[src]

type IntoIter = FastIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView)>

type IntoParIter = FastParIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView)>

impl<A: IntoAbstract, B: IntoAbstract, C: IntoAbstract, D: IntoAbstract, E: IntoAbstract, F: IntoAbstract> IntoFastIter for (A, B, C, D, E, F) where
    A::AbsView: FastAbstractMut,
    B::AbsView: FastAbstractMut,
    C::AbsView: FastAbstractMut,
    D::AbsView: FastAbstractMut,
    E::AbsView: FastAbstractMut,
    F::AbsView: FastAbstractMut,
    <A::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <B::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <C::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <D::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <E::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <F::AbsView as AbstractMut>::Index: From<usize> + Clone
[src]

type IntoIter = FastIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView, F::AbsView)>

type IntoParIter = FastParIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView, F::AbsView)>

impl<A: IntoAbstract, B: IntoAbstract, C: IntoAbstract, D: IntoAbstract, E: IntoAbstract, F: IntoAbstract, G: IntoAbstract> IntoFastIter for (A, B, C, D, E, F, G) where
    A::AbsView: FastAbstractMut,
    B::AbsView: FastAbstractMut,
    C::AbsView: FastAbstractMut,
    D::AbsView: FastAbstractMut,
    E::AbsView: FastAbstractMut,
    F::AbsView: FastAbstractMut,
    G::AbsView: FastAbstractMut,
    <A::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <B::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <C::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <D::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <E::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <F::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <G::AbsView as AbstractMut>::Index: From<usize> + Clone
[src]

type IntoIter = FastIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView, F::AbsView, G::AbsView)>

type IntoParIter = FastParIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView, F::AbsView, G::AbsView)>

impl<A: IntoAbstract, B: IntoAbstract, C: IntoAbstract, D: IntoAbstract, E: IntoAbstract, F: IntoAbstract, G: IntoAbstract, H: IntoAbstract> IntoFastIter for (A, B, C, D, E, F, G, H) where
    A::AbsView: FastAbstractMut,
    B::AbsView: FastAbstractMut,
    C::AbsView: FastAbstractMut,
    D::AbsView: FastAbstractMut,
    E::AbsView: FastAbstractMut,
    F::AbsView: FastAbstractMut,
    G::AbsView: FastAbstractMut,
    H::AbsView: FastAbstractMut,
    <A::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <B::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <C::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <D::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <E::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <F::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <G::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <H::AbsView as AbstractMut>::Index: From<usize> + Clone
[src]

type IntoIter = FastIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView, F::AbsView, G::AbsView, H::AbsView)>

type IntoParIter = FastParIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView, F::AbsView, G::AbsView, H::AbsView)>

impl<A: IntoAbstract, B: IntoAbstract, C: IntoAbstract, D: IntoAbstract, E: IntoAbstract, F: IntoAbstract, G: IntoAbstract, H: IntoAbstract, I: IntoAbstract> IntoFastIter for (A, B, C, D, E, F, G, H, I) where
    A::AbsView: FastAbstractMut,
    B::AbsView: FastAbstractMut,
    C::AbsView: FastAbstractMut,
    D::AbsView: FastAbstractMut,
    E::AbsView: FastAbstractMut,
    F::AbsView: FastAbstractMut,
    G::AbsView: FastAbstractMut,
    H::AbsView: FastAbstractMut,
    I::AbsView: FastAbstractMut,
    <A::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <B::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <C::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <D::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <E::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <F::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <G::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <H::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <I::AbsView as AbstractMut>::Index: From<usize> + Clone
[src]

type IntoIter = FastIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView, F::AbsView, G::AbsView, H::AbsView, I::AbsView)>

type IntoParIter = FastParIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView, F::AbsView, G::AbsView, H::AbsView, I::AbsView)>

impl<A: IntoAbstract, B: IntoAbstract, C: IntoAbstract, D: IntoAbstract, E: IntoAbstract, F: IntoAbstract, G: IntoAbstract, H: IntoAbstract, I: IntoAbstract, J: IntoAbstract> IntoFastIter for (A, B, C, D, E, F, G, H, I, J) where
    A::AbsView: FastAbstractMut,
    B::AbsView: FastAbstractMut,
    C::AbsView: FastAbstractMut,
    D::AbsView: FastAbstractMut,
    E::AbsView: FastAbstractMut,
    F::AbsView: FastAbstractMut,
    G::AbsView: FastAbstractMut,
    H::AbsView: FastAbstractMut,
    I::AbsView: FastAbstractMut,
    J::AbsView: FastAbstractMut,
    <A::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <B::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <C::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <D::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <E::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <F::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <G::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <H::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <I::AbsView as AbstractMut>::Index: From<usize> + Clone,
    <J::AbsView as AbstractMut>::Index: From<usize> + Clone
[src]

type IntoIter = FastIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView, F::AbsView, G::AbsView, H::AbsView, I::AbsView, J::AbsView)>

type IntoParIter = FastParIter<(A::AbsView, B::AbsView, C::AbsView, D::AbsView, E::AbsView, F::AbsView, G::AbsView, H::AbsView, I::AbsView, J::AbsView)>

Loading content...

Implementors

impl<T: IntoAbstract> IntoFastIter for T where
    T::AbsView: FastAbstractMut,
    <T::AbsView as AbstractMut>::Index: Clone
[src]

type IntoIter = FastIter<T::AbsView>

type IntoParIter = FastParIter<T::AbsView>

Loading content...