Rust cannot borrow as mutable

49 views Asked by At

There are two ndarrays, a and b I would like to parallel iterate through array a, and update array b at the same time.

a.par_iter().enumerate().for_each(|(i, data)| { b[i] = data + 1; });

However, I'm getting the message "cannot borrow b as mutable, as it is a captured variable in a Fn closure"

I know that I could use par_iter_mut() instead, but this only enables mutable on a, but not b.

0

There are 0 answers