summaryrefslogtreecommitdiff
path: root/ecs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-02-22 19:43:58 +0100
committerHampusM <hampus@hampusmat.com>2024-02-22 19:43:58 +0100
commit88ab4fb9d2345de272c7718437458c4a2943cf8c (patch)
treeb64ed708dca78083b5a16e60ddbfbeb7bd589800 /ecs
parent7e756b8c619bfb35327d13aa4f97e58458369a3f (diff)
feat(ecs): make Query implement IntoIterator
Diffstat (limited to 'ecs')
-rw-r--r--ecs/src/lib.rs13
1 files changed, 13 insertions, 0 deletions
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>,