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
We should more clearly and directly recommend that developers write their helper functions to take Commands (and friends) directly, instead of passing as references (&Commands). And by doing so, these helpers can look just like systems. As an example:
fnmy_system(commands:Commands,foo:Query<&Foo>){// we should recommend this:good_helper(commands.reborrow(), foo.reborrow());// instead of this:bad_helper(&mut commands,&foo);}// This is kind of annoying:fnbad_helper(commands:&mutCommands,foo:&Query<&Foo>){// ...}// This is easier to deal with:fngood_helper(commands:Commands,foo:Query<&Foo>){// ...}
We should recommend reborrowing in the top level docs for Commands and Query.
We can write a lint that would warn against taking &mut Commands in a function! It would probably be in the pedantic category, though.
The text was updated successfully, but these errors were encountered:
Quoting @ItsDoot in bevyengine/bevy#15657:
We can write a lint that would warn against taking
&mut Commands
in a function! It would probably be in the pedantic category, though.The text was updated successfully, but these errors were encountered: