From 88ab4fb9d2345de272c7718437458c4a2943cf8c Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 22 Feb 2024 19:43:58 +0100 Subject: feat(ecs): make Query implement IntoIterator --- ecs/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ecs/src/lib.rs') diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index 6106862..df46a5a 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -129,6 +129,19 @@ where } } +impl<'world, Comps> IntoIterator for &'world mut Query<'world, Comps> +where + Comps: ComponentSequence + 'world, +{ + type IntoIter = QueryComponentIter<'world, Comps>; + type Item = Comps::MutRefs<'world>; + + fn into_iter(self) -> Self::IntoIter + { + self.iter_mut() + } +} + pub struct QueryComponentIter<'world, Comps> { entity_iter: SliceIterMut<'world, Entity>, -- cgit v1.2.3-18-g5258