From 624e6dd450944e67d84ad7afda54ae2abd277aba Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 23 Jul 2026 17:38:51 +0200 Subject: refactor(engine-ecs): remove distinction between query terms with & without a field --- engine-ecs/src/query/flexible.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engine-ecs/src/query/flexible.rs') diff --git a/engine-ecs/src/query/flexible.rs b/engine-ecs/src/query/flexible.rs index 66d62c6..fd1e30e 100644 --- a/engine-ecs/src/query/flexible.rs +++ b/engine-ecs/src/query/flexible.rs @@ -19,7 +19,7 @@ impl<'world, const MAX_TERM_CNT: usize> Query<'world, MAX_TERM_CNT> { /// Iterates over the entities matching this query. #[must_use] - pub fn iter(&self) -> Iter<'_> + pub fn iter(&self) -> Iter<'_, 'world> { Iter { iter: self @@ -52,10 +52,10 @@ impl<'world, const MAX_TERM_CNT: usize> Query<'world, MAX_TERM_CNT> } } -impl<'query, const MAX_TERM_CNT: usize> IntoIterator for &'query Query<'_, MAX_TERM_CNT> +impl<'query, 'world, const MAX_TERM_CNT: usize> IntoIterator for &'query Query<'world, MAX_TERM_CNT> { - type IntoIter = Iter<'query>; - type Item = EntityHandle<'query>; + type IntoIter = Iter<'query, 'world>; + type Item = EntityHandle<'world>; fn into_iter(self) -> Self::IntoIter { @@ -63,15 +63,15 @@ impl<'query, const MAX_TERM_CNT: usize> IntoIterator for &'query Query<'_, MAX_T } } -pub struct Iter<'query> +pub struct Iter<'query, 'world> { - iter: QueryEntityIter<'query>, - world: &'query World, + iter: QueryEntityIter<'query, 'world>, + world: &'world World, } -impl<'query> Iterator for Iter<'query> +impl<'query, 'world> Iterator for Iter<'query, 'world> { - type Item = EntityHandle<'query>; + type Item = EntityHandle<'world>; fn next(&mut self) -> Option { @@ -85,8 +85,8 @@ type ComponentIterMapFnOutput<'a> = Zip, EntityIter<'a>>; type ComponentIterMapFn = for<'a> fn(&'a Archetype) -> ComponentIterMapFnOutput<'a>; -type QueryEntityIter<'query> = FlatMap< - ArchetypeRefIter<'query, 'query>, - ComponentIterMapFnOutput<'query>, +type QueryEntityIter<'query, 'world> = FlatMap< + ArchetypeRefIter<'world, 'query>, + ComponentIterMapFnOutput<'world>, ComponentIterMapFn, >; -- cgit v1.2.3-18-g5258