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`
This commit is contained in:
François 2022-10-10 23:09:08 +00:00
parent 9a597b758e
commit b4accebe10

View file

@ -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()
}
}