Description
What problem does this solve or what need does it fill?
The MapEntities
trait (https://github.com/bevyengine/bevy/blob/main/crates/bevy_ecs/src/entity/map_entities.rs#L46)
pub trait MapEntities {
fn map_entities<M: EntityMapper>(&mut self, entity_mapper: &mut M);
}
requires a mutable access to the EntityMapper
: &mut M
This is because the SceneEntityMapper
might generate a new Entity, as seen here: https://github.com/bevyengine/bevy/blob/main/crates/bevy_ecs/src/entity/map_entities.rs#L81
but there are a lot of cases where you might want to just map an entity using an immutable HashMap, in which case you only need a &dyn EntityMapper
.
I run into cases where the parallelism of my systems is lowered because I am forced to provide a mutable access to the EntityMapper even though a non-mutable access would be okay. I would appreciate having a way to call map_entities
without requiring a mutable access to entity_mapper
What solution would you like?
Maybe the MapEntities
trait could have 2 functions map_entities_mut
and map_entities
? I haven't thought this through.