`&mut [T]` should implement `rayon::slice::ParallelSliceMut`
ewoolsey opened this issue · comments
I think there's a good chance I'm misunderstanding something here because I imagine this should already work.
I have
let mut_slice: &mut [T] = ...
I should definitely be able to call
mut_slice.par_iter_mut()...
But I can't. Perhaps IntoParallelIterator should work here too?
But I can't.
What's the error? As long as you satisfy T: Send
and have the traits in scope, it should be fine.
This is a more complete example of what I actually want to accomplish
let (parent_layer, child_layer) = storage.split_at_mut(1 << current_depth);
parent_layer
.par_iter_mut()
.enumerate()
.for_each(|(i, value)| {
let left = &child_layer[2 * i];
let right = &child_layer[2 * i + 1];
*value = H::hash_node(left, right);
});
But I can't.
What's the error? As long as you satisfy
T: Send
and have the traits in scope, it should be fine.
My god I must need some rest. T: Send
was the problem. When I saw the error my brain for some reason assumed the missing trait bound was from &mut [T]
and not from T...
Apologies for posting this issue, but thanks so much for your help!
No worries!