diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index 028182e69f..15e4861fe0 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -1321,7 +1321,6 @@ fn insert_resource(resource: R) -> impl Command { fn log_components(entity: Entity, world: &mut World) { let debug_infos: Vec<_> = world .inspect_entity(entity) - .into_iter() .map(|component_info| component_info.name()) .collect(); info!("Entity {:?}: {:?}", entity, debug_infos); diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index d509eaa349..9ace589952 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -479,7 +479,7 @@ impl World { /// Returns the components of an [`Entity`] through [`ComponentInfo`]. #[inline] - pub fn inspect_entity(&self, entity: Entity) -> Vec<&ComponentInfo> { + pub fn inspect_entity(&self, entity: Entity) -> impl Iterator { let entity_location = self .entities() .get(entity) @@ -498,7 +498,6 @@ impl World { archetype .components() .filter_map(|id| self.components().get_info(id)) - .collect() } /// Returns an [`EntityWorldMut`] for the given `entity` (if it exists) or spawns one if it doesn't exist. @@ -3162,31 +3161,31 @@ mod tests { let bar_id = TypeId::of::(); let baz_id = TypeId::of::(); assert_eq!( - to_type_ids(world.inspect_entity(ent0)), + to_type_ids(world.inspect_entity(ent0).collect()), [Some(foo_id), Some(bar_id), Some(baz_id)].into() ); assert_eq!( - to_type_ids(world.inspect_entity(ent1)), + to_type_ids(world.inspect_entity(ent1).collect()), [Some(foo_id), Some(bar_id)].into() ); assert_eq!( - to_type_ids(world.inspect_entity(ent2)), + to_type_ids(world.inspect_entity(ent2).collect()), [Some(bar_id), Some(baz_id)].into() ); assert_eq!( - to_type_ids(world.inspect_entity(ent3)), + to_type_ids(world.inspect_entity(ent3).collect()), [Some(foo_id), Some(baz_id)].into() ); assert_eq!( - to_type_ids(world.inspect_entity(ent4)), + to_type_ids(world.inspect_entity(ent4).collect()), [Some(foo_id)].into() ); assert_eq!( - to_type_ids(world.inspect_entity(ent5)), + to_type_ids(world.inspect_entity(ent5).collect()), [Some(bar_id)].into() ); assert_eq!( - to_type_ids(world.inspect_entity(ent6)), + to_type_ids(world.inspect_entity(ent6).collect()), [Some(baz_id)].into() ); }