I'm trying to implement a
par_swap_remove, to parallelize a
Vec::swap_remove using rayon.
The idea is to copy the n-th last elements of the Vec into the positions of n indices which are to be removed (assuming no duplicates in the indices).
I've tried for about 1.5 hours now and this is what I've come up with. It segfaults and doesn't do what it's supposed to.
I'm extremely inexperienced with the dark arts of unsafe Rust and have struggled to share the Vec across threads - which is why I created the
SafeSync struct. How do I do this properly, without locking?
Additionally, I couldn't find a method to directly alter the length of the Vec. (see FIXME in the playground)
Furthermore, I couldn't make it not consume the Vec, when using
SafeSync to pass the Vec between threads. I'd much rather have the procedure take a mutable reference to the Vec.
I'm worn out from battling the borrow-checker. Please help me.