You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever I come back to my Bevy projects after a while, something that I always find to be awkward/unintuitive is adding mutable parameters to a query. For example, in the simplest possible case you need to add four mentions of mut:
mut items is only necessary because you need a mutable reference to items.
&mut items is only necessary because you can only construct the query's iterator from a mutable reference to it.
mut item is needed since it's secretly Mut<T> instead of &mut T, but that's mostly fine.
As I see it, two of these would be unnecessary if there was a way to consume the query itself into an iterator. e.g.
fnsystem(items:Query<&mutItem>){formut item in items {// ..}}
Personally I find this easier to read and remember, and I'd imagine the reduced tedium of the transformation would be better for prototyping ideas or just quickly debugging.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Whenever I come back to my Bevy projects after a while, something that I always find to be awkward/unintuitive is adding mutable parameters to a query. For example, in the simplest possible case you need to add four mentions of
mut
:Query<&mut Item>
is absolutely fine, no problems.mut items
is only necessary because you need a mutable reference toitems
.&mut items
is only necessary because you can only construct the query's iterator from a mutable reference to it.mut item
is needed since it's secretlyMut<T>
instead of&mut T
, but that's mostly fine.As I see it, two of these would be unnecessary if there was a way to consume the query itself into an iterator. e.g.
Personally I find this easier to read and remember, and I'd imagine the reduced tedium of the transformation would be better for prototyping ideas or just quickly debugging.
Beta Was this translation helpful? Give feedback.
All reactions