From 85312f76169e61fbbf9d1d23fbba60ca2302e0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 10 Oct 2022 23:09:08 +0000 Subject: [PATCH] scenes: simplify return type of iter_instance_entities (#5994) # Objective - Taking the API improvement out of #5431 - `iter_instance_entities` used to return an option of iterator, now it just returns an iterator --- ## Changelog - If you use `SceneSpawner::iter_instance_entities`, it no longer returns an `Option`. The iterator will be empty if the return value used to be `None` --- crates/bevy_scene/src/scene_spawner.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/bevy_scene/src/scene_spawner.rs b/crates/bevy_scene/src/scene_spawner.rs index 73eaa93e4cd18..1a377c6b7ae07 100644 --- a/crates/bevy_scene/src/scene_spawner.rs +++ b/crates/bevy_scene/src/scene_spawner.rs @@ -295,14 +295,19 @@ impl SceneSpawner { self.spawned_instances.contains_key(&instance_id) } - /// Get an iterator over the entities in an instance, once it's spawned + /// Get an iterator over the entities in an instance, once it's spawned. + /// + /// Before the scene is spawned, the iterator will be empty. Use [`Self::instance_is_ready`] + /// to check if the instance is ready. pub fn iter_instance_entities( &'_ self, instance_id: InstanceId, - ) -> Option + '_> { + ) -> impl Iterator + '_ { self.spawned_instances .get(&instance_id) .map(|instance| instance.entity_map.values()) + .into_iter() + .flatten() } }