summaryrefslogtreecommitdiff
path: root/ecs/src/query.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-06-20 21:32:46 +0200
committerHampusM <hampus@hampusmat.com>2024-06-20 21:32:46 +0200
commit681fca5c465191e37714ed07937efec8b0c8b197 (patch)
treefd609df5737a678a32c2bbe17315f1e163a23d48 /ecs/src/query.rs
parent87a4230d5cbe8741c88edecbecff510bc1736fef (diff)
refactor(ecs): fix Clippy lints
Diffstat (limited to 'ecs/src/query.rs')
-rw-r--r--ecs/src/query.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/ecs/src/query.rs b/ecs/src/query.rs
index dcd0b0e..dc6b5f0 100644
--- a/ecs/src/query.rs
+++ b/ecs/src/query.rs
@@ -1,10 +1,14 @@
-use std::any::{type_name, Any};
+use std::any::Any;
use std::collections::HashSet;
use std::iter::{Flatten, Map};
use std::marker::PhantomData;
use std::sync::{Arc, Weak};
-use crate::component::storage::{Archetype, ArchetypeRefIter};
+use crate::component::storage::{
+ Archetype,
+ ArchetypeRefIter,
+ Storage as ComponentStorage,
+};
use crate::component::{
Id as ComponentId,
IsOptional as ComponentIsOptional,
@@ -16,7 +20,7 @@ use crate::system::{
Param as SystemParam,
System,
};
-use crate::{ComponentStorage, EntityComponent, WorldData};
+use crate::{EntityComponent, WorldData};
#[derive(Debug)]
pub struct Query<'world, Comps>
@@ -32,19 +36,20 @@ impl<'world, Comps> Query<'world, Comps>
where
Comps: ComponentSequence,
{
+ /// Iterates over the entities matching this query.
#[must_use]
pub fn iter<'this>(&'this self) -> ComponentIter<'world, Comps>
where
'this: 'world,
{
#[cfg(feature = "debug")]
- tracing::debug!("Searching for {}", type_name::<Comps>());
+ tracing::debug!("Searching for {}", std::any::type_name::<Comps>());
+ #[allow(clippy::map_flatten)]
ComponentIter {
entities: self
.component_storage
.find_entities(&Comps::ids())
- .unwrap_or_else(|| panic!("Could not find {:?}", type_name::<Comps>()))
.map((|archetype| archetype.components.as_slice()) as ComponentIterMapFn)
.flatten(),
comps_pd: PhantomData,
@@ -136,7 +141,7 @@ where
#[cfg(feature = "debug")]
tracing::debug!(
"Adding archetypes lookup entry for components: ({})",
- type_name::<Comps>()
+ std::any::type_name::<Comps>()
);
component_storage_lock.add_archetype_lookup_entry(