diff --git a/macros/src/generate/world.rs b/macros/src/generate/world.rs index 31e59fc..98b2c36 100644 --- a/macros/src/generate/world.rs +++ b/macros/src/generate/world.rs @@ -838,6 +838,22 @@ fn section_archetype(archetype_data: &DataArchetype) -> TokenStream { } } + impl<'a> #ArchetypeSlices<'a> { + #[inline(always)] + pub fn zipped( + &'a self, + ) -> impl Iterator, #(&'a #Component),*)> { + ::gecs::__internal::izip!(self.entity.iter(), #(self.#component.iter()),*) + } + + #[inline(always)] + pub fn zipped_mut( + &'a mut self, + ) -> impl Iterator, #(&'a mut #Component),*)> { + ::gecs::__internal::izip!(self.entity.iter(), #(self.#component.iter_mut()),*) + } + } + impl<'a> ArchetypeCanResolve<'a, #ArchetypeView<'a>, Entity<#Archetype>> for #Archetype { #[inline(always)] fn resolve_for(&self, key: Entity<#Archetype>) -> Option { diff --git a/src/archetype/slices.rs b/src/archetype/slices.rs index 4815b16..0c60232 100644 --- a/src/archetype/slices.rs +++ b/src/archetype/slices.rs @@ -4,7 +4,7 @@ use crate::entity::Entity; use crate::traits::Archetype; macro_rules! declare_slices_n { - ($slices:ident, $slices_mut:ident, $n:literal) => { + ($slices:ident, $n:literal) => { seq!(I in 0..$n { pub trait $slices<'a, A: Archetype, #(T~I,)*> { fn new(entities: &'a [Entity], #(s~I: &'a mut [T~I],)*) -> Self; @@ -15,11 +15,11 @@ macro_rules! declare_slices_n { // Declare slices for up to 16 components. seq!(N in 1..=16 { - declare_slices_n!(Slices~N, SlicesMut~N, N); + declare_slices_n!(Slices~N, N); }); // Declare additional slices for up to 32 components. #[cfg(feature = "32_components")] seq!(N in 17..=32 { - declare_slices_n!(Slices~N, SlicesMut~N, N); + declare_slices_n!(Slices~N, N); }); diff --git a/src/lib.rs b/src/lib.rs index d30b97b..93e0a1d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -801,4 +801,7 @@ pub mod __internal { pub use traits::{World, WorldHas}; pub use traits::{Archetype, ArchetypeHas}; pub use traits::{View, ViewHas}; + + + pub use itertools::izip as izip; }