pub trait IntoIter {
    type IntoIter: Iterator;
    type IntoParIter;

    fn iter(self) -> Self::IntoIter;
    fn iter_by<D: 'static>(self) -> Self::IntoIter;
    fn par_iter(self) -> Self::IntoParIter;
}
Expand description

Trait used to create iterators.
Yields Mut for mutable components.

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

Required Associated Types

Required Methods

Returns an iterator over SparseSet.

Yields Mut for tracked mutable components.
It derefs to the component and will flag mutation.

Example
use shipyard::{Component, EntitiesViewMut, IntoIter, ViewMut, World};

#[derive(Component, Clone, Copy)]
struct U32(u32);

#[derive(Component)]
struct USIZE(usize);

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), (USIZE(0), U32(1)));
entities.add_entity((&mut usizes, &mut u32s), (USIZE(2), U32(3)));

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

Returns an iterator over SparseSet, its order is based on D.

Returns Mut when yielding tracked mutable components.
It derefs to the component and will flag mutation.

Available on crate feature parallel only.

Returns a parallel iterator over SparseSet.

Yields Mut for tracked mutable components.
It derefs to the component and will flag mutation.

Example
use rayon::prelude::ParallelIterator;
use shipyard::{Component, EntitiesViewMut, IntoIter, ViewMut, World};

#[derive(Component, Clone, Copy)]
struct U32(u32);

#[derive(Component)]
struct USIZE(usize);

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), (USIZE(0), U32(1)));
entities.add_entity((&mut usizes, &mut u32s), (USIZE(2), U32(3)));

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

Implementations on Foreign Types

Available on crate feature parallel only.
Available on crate feature parallel only.
Available on crate feature parallel only.
Available on crate feature parallel only.
Available on crate feature parallel only.
Available on crate feature parallel only.
Available on crate feature parallel only.
Available on crate feature parallel only.
Available on crate feature parallel only.
Available on crate feature parallel only.

Implementors