-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Is it possible to do nested for loops? #706
Comments
You can't mutably borrow twice. What are you trying to do? Perhaps it can be rewritten because this is, as you said, a borrow checker issue with your implementation and not specs-specific |
I just want to do a n^2 component operation on some component. Would I have to iterate over entities instead and use get_mut then to make this work? |
There are many ways to do it and it's been answered a lot on stackoverflow depending on your situation, which you won't give details on. You can split the iterator, copy it and walk that, use interior mutability, or pass a message to another system and have that other system mutate it. Or just rewrite it to not have a nested loop. If it's for collision, you can use ncollide and just query the collision world. |
Note that you can use |
Is it possible to do nested for loops simply within system iterations? If I call join on a &mut component then try to iterate inside that component using join again, the borrow checker complains. What is the intended way to have every entity operate on every entity as an example, mutably.
The text was updated successfully, but these errors were encountered: