Skip to main content

ParCollectionMut

Trait ParCollectionMut 

Source
pub trait ParCollectionMut: ConcurrentCollectionMut + ParCollection {
    // Provided method
    fn par_mut(&mut self) -> ParIter<Self::IterMut<'_>, Id<&mut Self::Item>> { ... }
}
Expand description

A collection from which a mutable parallel iterator can be created repeatedly using par_mut() method.

Sequential counterpart: iter_mut().

Provided Methods§

Source

fn par_mut(&mut self) -> ParIter<Self::IterMut<'_>, Id<&mut Self::Item>>

Returns a parallel iterator over mutable references to collection items.

§Example
use orx_parallel::*;

let mut values = vec![1, 2, 3, 4];

ParCollectionMut::par_mut(&mut values).for_each(|x| *x *= 2);
assert_eq!(values, vec![2, 4, 6, 8]);

// alternatively
values.par_mut().for_each(|x| *x *= 2);
assert_eq!(values, vec![4, 8, 12, 16]);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§