-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cast query of mutable components to query of immutable #4606
Labels
A-ECS
Entities, components, systems, and events
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
Comments
alice-i-cecile
added
A-ECS
Entities, components, systems, and events
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
labels
Apr 26, 2022
I agree here. I'd really like to see a unified API for casting mutable ECS data into its immutable form, in order to resolve this sort of challenge. You see this with e.g. |
inodentry
pushed a commit
to IyesGames/bevy
that referenced
this issue
Aug 8, 2022
…#5376) # Objective - Allows conversion of mutable queries to immutable queries. - Fixes bevyengine#4606 ## Solution - Add `to_readonly` method on `Query`, which uses `QueryState::as_readonly` - `AsRef` is not feasible because creation of new queries is needed. --- ## Changelog ### Added - Allows conversion of mutable queries to immutable queries using `Query::to_readonly`.
james7132
pushed a commit
to james7132/bevy
that referenced
this issue
Oct 28, 2022
…#5376) # Objective - Allows conversion of mutable queries to immutable queries. - Fixes bevyengine#4606 ## Solution - Add `to_readonly` method on `Query`, which uses `QueryState::as_readonly` - `AsRef` is not feasible because creation of new queries is needed. --- ## Changelog ### Added - Allows conversion of mutable queries to immutable queries using `Query::to_readonly`.
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this issue
Feb 1, 2023
…#5376) # Objective - Allows conversion of mutable queries to immutable queries. - Fixes bevyengine#4606 ## Solution - Add `to_readonly` method on `Query`, which uses `QueryState::as_readonly` - `AsRef` is not feasible because creation of new queries is needed. --- ## Changelog ### Added - Allows conversion of mutable queries to immutable queries using `Query::to_readonly`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-ECS
Entities, components, systems, and events
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
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
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 likeCanQuery<ComponentType>
.The text was updated successfully, but these errors were encountered: