-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Cast query of mutable components to query of immutable #4606
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to use
Description
Because of Rust borrow checker I'm usually forced to pass around entities and queries. But there seems to be a problem when I've got a mutable query but it suffices to have immutable one, like
fn some_function(entities: &Vec<Entity>, query: &Query<&SomeComponent>){...}
fn some_system(some_entities: Res<Vec<Entity>>, query: Query<&mut SomeComponent>)
{
for mut c in query.iter_mut() {...};
some_function(some_entities, query);
}As far as I can see there is no way to cast the query although it seems reasonable to do so. I believe there should exist some implementation of AsRef trait or perhaps some new trait like CanQuery<ComponentType>.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to use