summaryrefslogtreecommitdiff
path: root/ecs/src/query/flexible.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2025-04-22 18:06:59 +0200
committerHampusM <hampus@hampusmat.com>2025-04-22 18:06:59 +0200
commitfb47933690dfb54206e9f136902671b19ddd34e0 (patch)
treeffdb6640ea896b69b0267a9526657b9ed454184f /ecs/src/query/flexible.rs
parentd9ac86a1f6ec541a399794f9f81381753cfea5f6 (diff)
refactor(ecs): fix clippy lints
Diffstat (limited to 'ecs/src/query/flexible.rs')
-rw-r--r--ecs/src/query/flexible.rs31
1 files changed, 15 insertions, 16 deletions
diff --git a/ecs/src/query/flexible.rs b/ecs/src/query/flexible.rs
index 3e72b34..6d65ee0 100644
--- a/ecs/src/query/flexible.rs
+++ b/ecs/src/query/flexible.rs
@@ -2,13 +2,8 @@
use std::iter::{repeat_n, FlatMap, RepeatN, Zip};
use crate::component::storage::archetype::{Archetype, EntityIter};
-use crate::component::storage::{
- ArchetypeRefIter,
- ArchetypeSearchTerms,
- Storage as ComponentStorage,
-};
+use crate::component::storage::{ArchetypeRefIter, ArchetypeSearchTerms};
use crate::entity::Handle as EntityHandle;
-use crate::lock::ReadGuard;
use crate::query::Terms;
use crate::World;
@@ -17,7 +12,6 @@ use crate::World;
pub struct Query<'world, const MAX_TERM_CNT: usize>
{
world: &'world World,
- component_storage: ReadGuard<'world, ComponentStorage>,
terms: Terms<MAX_TERM_CNT>,
}
@@ -30,6 +24,8 @@ impl<'world, const MAX_TERM_CNT: usize> Query<'world, MAX_TERM_CNT>
Iter {
world: self.world,
iter: self
+ .world
+ .data
.component_storage
.search_archetypes(ArchetypeSearchTerms {
required_components: &self.terms.required_components,
@@ -46,15 +42,18 @@ impl<'world, const MAX_TERM_CNT: usize> Query<'world, MAX_TERM_CNT>
pub(crate) fn new(world: &'world World, terms: Terms<MAX_TERM_CNT>) -> Self
{
- Self {
- world,
- component_storage: world
- .data
- .component_storage
- .read_nonblock()
- .expect("Failed to acquire read-only component storage lock"),
- terms,
- }
+ Self { world, terms }
+ }
+}
+
+impl<'query, const MAX_TERM_CNT: usize> IntoIterator for &'query Query<'_, MAX_TERM_CNT>
+{
+ type IntoIter = Iter<'query>;
+ type Item = EntityHandle<'query>;
+
+ fn into_iter(self) -> Self::IntoIter
+ {
+ self.iter()
}
}