Reputation: 391
I need to mutably iterate over the Vec
model.circles
, so I get all permutations of two elements.
However, I can't get it to compile:
for ij in (0..model.circles.len()).permutations(2) {
let i = ij[0];
let j = ij[1];
let circle = &mut model.circles[i];
let other = &mut model.circles[j]; // cannot borrow `model.circles` as mutable more than once at a time
// Mutating both elements
}
I get this error:
cannot borrow `model.circles` as mutable more than once at a time
How can I make this work?
Upvotes: 0
Views: 33