Skip to content

Commit

Permalink
scenes: simplify return type of iter_instance_entities (#5994)
Browse files Browse the repository at this point in the history
# 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`
  • Loading branch information
mockersf committed Oct 10, 2022
1 parent 9a597b7 commit b4acceb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/bevy_scene/src/scene_spawner.rs
Expand Up @@ -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<Item = Entity> + '_> {
) -> impl Iterator<Item = Entity> + '_ {
self.spawned_instances
.get(&instance_id)
.map(|instance| instance.entity_map.values())
.into_iter()
.flatten()
}
}

Expand Down

0 comments on commit b4acceb

Please sign in to comment.