I've got an array of u8
which I will be partitioning in a complicated way.
Is it possible to update it from multiple rayon tasks? Sort of like this:
let mut pixels = vec![0; w * h];
rayon::scope(|s| {
s.spawn(move |_s| {
my_fn(&mut pixels);
}
}
BTW, I know about into_par_iter
, but I can't partition the pixels ahead of time.
I.e. the partitioning scheme will be recursive and will depend on the outcome of some of the tasks.
FYI, I will be passing metadata about the pixels back and forth, which will influence which part of pixels
my_fn
will be working on, which is not shown here.
I'm getting this error, which prevents me from borrowing pixels
afterwards.
| ------ variable moved due to use in closure
...
999 | write_image(&pixels)
| ^^^^^^^ value borrowed here after move
Should I just give up on this design, or is there some way to make it work?