pub trait ConcurrentCollectionMut: ConcurrentCollection {
type IterMut<'a>: ConcurrentIter<Item = &'a mut Self::Item>
where Self: 'a;
// Required method
fn con_iter_mut(&mut self) -> Self::IterMut<'_>;
}Expand description
A type implementing ConcurrentCollectionMut is a collection owning the elements such that
- if the elements are of type
T, - then, non-consuming
con_iter_mutmethod can be called multiple times to create concurrent iterators; i.e.,ConcurrentIter, yielding references to the elements&T; and further, - non-consuming mutable
con_iter_mutmethod can be called to create concurrent iterators yielding mutable references to elements&mut T.
This trait can be considered as the concurrent counterpart of the CollectionMut trait.
§Examples
use orx_concurrent_iter::*;
let mut data = vec![1, 2];
let con_iter = data.con_iter_mut();
assert_eq!(con_iter.next(), Some(&mut 1));
assert_eq!(con_iter.next(), Some(&mut 2));
assert_eq!(con_iter.next(), None);
let con_iter = data.con_iter_mut();
while let Some(x) = con_iter.next() {
*x *= 100;
}
assert_eq!(data, vec![100, 200]);Required Associated Types§
Sourcetype IterMut<'a>: ConcurrentIter<Item = &'a mut Self::Item>
where
Self: 'a
type IterMut<'a>: ConcurrentIter<Item = &'a mut Self::Item> where Self: 'a
Type of the mutable concurrent iterator that this type can create with con_iter_mut method.
Required Methods§
Sourcefn con_iter_mut(&mut self) -> Self::IterMut<'_>
fn con_iter_mut(&mut self) -> Self::IterMut<'_>
Creates a concurrent iterator to mutable references of the underlying data; i.e., &mut Self::Item.
§Examples
use orx_concurrent_iter::*;
let mut data = vec![1, 2];
let con_iter = data.con_iter_mut();
assert_eq!(con_iter.next(), Some(&mut 1));
assert_eq!(con_iter.next(), Some(&mut 2));
assert_eq!(con_iter.next(), None);
let con_iter = data.con_iter_mut();
while let Some(x) = con_iter.next() {
*x *= 100;
}
assert_eq!(data, vec![100, 200]);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.