let mut tmps = vec![vec![0_i32; n]; 2];
let i = 20;
let rhs = &tmps[(i + 1) % 2];
let res = &mut tmps[i % 2];
I'm doing something of the form:
for x in lst {
new_value = f(x, old_value);
swap storage for new_value, old_value
I'm trying to use the tmps
to store both old_value and new_value -- and running into this borrow issue. I understand where the compiler is coming from (i'ts not seeing the %2 as mutually exclusive).
What is the idiomatic way to resolve this ?