Allow immutable iter on Queries which contain mutable references #753
Labels
A-ECS
Entities, components, systems, and events
C-Code-Quality
A section of code that is hard to understand or change
C-Usability
A simple quality-of-life change that makes Bevy easier to use
Milestone
What problem does this solve or what need does it fill?
The new Query api follows rust conventions by using .iter() to create iterators over queries of immutable component references and .iter_mut() to create iterators over queries of mutable component references. However, it deviates from rust convention by not allowing iter() to be called on queries of mutable component references.
Describe the solution would you like?
I expect .iter() on a mutable iterable object to return an iterator of immutable references rather than fail with a compilation error. That would make the API consistent with other similar APIs in rust and allow programmers to signal clearly where they are iterating over a query which is used mutably elsewhere in the system but is being used immutable at the moment.
Describe the alternative(s) you've considered?
I have yet to encounter a case where calling iter_mut is a serious problem, so keeping the existing API is certainly an alternative.
The text was updated successfully, but these errors were encountered: