Skip to content

Commit b4acceb

Browse files
committed
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`
1 parent 9a597b7 commit b4acceb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/bevy_scene/src/scene_spawner.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,19 @@ impl SceneSpawner {
295295
self.spawned_instances.contains_key(&instance_id)
296296
}
297297

298-
/// Get an iterator over the entities in an instance, once it's spawned
298+
/// Get an iterator over the entities in an instance, once it's spawned.
299+
///
300+
/// Before the scene is spawned, the iterator will be empty. Use [`Self::instance_is_ready`]
301+
/// to check if the instance is ready.
299302
pub fn iter_instance_entities(
300303
&'_ self,
301304
instance_id: InstanceId,
302-
) -> Option<impl Iterator<Item = Entity> + '_> {
305+
) -> impl Iterator<Item = Entity> + '_ {
303306
self.spawned_instances
304307
.get(&instance_id)
305308
.map(|instance| instance.entity_map.values())
309+
.into_iter()
310+
.flatten()
306311
}
307312
}
308313

0 commit comments

Comments
 (0)