Closed musjj closed 2 months ago
The more idiomatic approach would most likely be
fn foobar(mut world: World) {
let mut cmd = CommandBuffer::new();
{
let foobar_query = world.query::<&mut f32>();
// use the query here
}
cmd.run_on(&mut world);
}
but in principle, yes the query and its borrow of the world
must end before cmd.run_on(..)
can have exclusive/mutable access to world
.
Typically you consume queries in a for
loop or some sort of iterator construction, as illustrated in various examples. It They are then implicitly dropped after you're done with them.
Thanks, that works for me.
Is there a way to run commands after performing a query? I tried using a
CommandBuffer
, but this doesn't satisfy the borrow checker:It seems to work after manually dropping
foobar_query
:But that's not really ideal in terms of ergonomics.