pub trait ConcurrentCollection {
type Item;
type Iterable<'i>: ConcurrentIterable<Item = &'i Self::Item>
where Self: 'i;
// Required method
fn as_concurrent_iterable(&self) -> Self::Iterable<'_>;
// Provided method
fn con_iter(&self) -> <Self::Iterable<'_> as ConcurrentIterable>::Iter { ... }
}
Expand description
A type implementing ConcurrentCollection
is a collection owning the elements such that
- if the elements are of type
T
, - then, non-consuming
con_iter
method can be called multiple times to create concurrent iterators; i.e.,ConcurrentIter
, yielding references to the elements&T
.
This trait can be considered as the concurrent counterpart of the Collection
trait.
§Examples
use orx_concurrent_iter::*;
let data = vec![1, 2];
let con_iter = data.con_iter();
assert_eq!(con_iter.next(), Some(&1));
assert_eq!(con_iter.next(), Some(&2));
assert_eq!(con_iter.next(), None);
Required Associated Types§
Sourcetype Iterable<'i>: ConcurrentIterable<Item = &'i Self::Item>
where
Self: 'i
type Iterable<'i>: ConcurrentIterable<Item = &'i Self::Item> where Self: 'i
Type of the ConcurrentIterable that reference of this type implements.
Required Methods§
Sourcefn as_concurrent_iterable(&self) -> Self::Iterable<'_>
fn as_concurrent_iterable(&self) -> Self::Iterable<'_>
Returns the ConcurrentIterable that a reference of this type can create.
Provided Methods§
Sourcefn con_iter(&self) -> <Self::Iterable<'_> as ConcurrentIterable>::Iter
fn con_iter(&self) -> <Self::Iterable<'_> as ConcurrentIterable>::Iter
A type implementing ConcurrentCollection
is a collection owning the elements such that
- if the elements are of type
T
, - then, non-consuming
con_iter
method can be called multiple times to create concurrent iterators; i.e.,ConcurrentIter
, yielding references to the elements&T
.
This trait can be considered as the concurrent counterpart of the Collection
trait.
§Examples
use orx_concurrent_iter::*;
let data = vec![1, 2];
let con_iter = data.con_iter();
assert_eq!(con_iter.next(), Some(&1));
assert_eq!(con_iter.next(), Some(&2));
assert_eq!(con_iter.next(), None);
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.