So far, the only getting flattened is my brain, as I bang my head against the desk...
I'm trying to convert an ECS Query (as per Query), into a list Vector of tuples, and failing. The code looks like:
#[derive(Component, Debug)]
struct KeyMover {
is_movable: bool
}
fn cycle_the_hat(mut tunnel_pos: Query<&mut KeyMover>) {
let mut foo: Vec<&mut KeyMover> = tunnel_pos.iter_mut().collect();
for beta in foo {
println!("alpha: , beta: {:?}", beta);
}
// If I understand it, this query->access is identical to the one above - but works.
for mut beta in &mut tunnel_pos {
println!("beta: {:?}", beta);
}
}
The error I'm getting:
The strange thing, it works fine if I take out the iter_mut()
(and the Vector mut). And originally, I had other parameters to the Query, not mutable (like entity_id) - I thought having a mixed mutable/immutable set of parameters might be causing problems, but apparently not.
I've tried too many permutations of code here, including adding a turbofish to the collect()
, but no joy so far. Any insight would be greatly appreciated. Or any other way of flattening a Query, if I'm missing something - the docs have a million options.
And one of the things I considered, is that it's a lifetime issue, but if so, I don't see how to fix it.
Another thing I tried, "unwrapping" the object:
Shockingly, it did not work. One thing that I don't understand, is where the Mut<_, KeyMover>
is coming from, I'd have thought it should be Mut<KeyMover>
(not that I can unwrap that, either).