diff options
author | HampusM <hampus@hampusmat.com> | 2024-02-22 19:43:58 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-02-22 19:43:58 +0100 |
commit | 88ab4fb9d2345de272c7718437458c4a2943cf8c (patch) | |
tree | b64ed708dca78083b5a16e60ddbfbeb7bd589800 | |
parent | 7e756b8c619bfb35327d13aa4f97e58458369a3f (diff) |
feat(ecs): make Query implement IntoIterator
-rw-r--r-- | ecs/src/lib.rs | 13 |
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>, |