Trait ConcurrentCollection

Source
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§

Source

type Item

Type of the element that the concurrent iterator yields.

Source

type Iterable<'i>: ConcurrentIterable<Item = &'i Self::Item> where Self: 'i

Type of the ConcurrentIterable that reference of this type implements.

Required Methods§

Source

fn as_concurrent_iterable(&self) -> Self::Iterable<'_>

Returns the ConcurrentIterable that a reference of this type can create.

Provided Methods§

Source

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.

Implementors§

Source§

impl<X> ConcurrentCollection for X
where X: IntoConcurrentIter, for<'a> &'a X: IntoConcurrentIter<Item = &'a <X as IntoConcurrentIter>::Item>,

Source§

type Item = <X as IntoConcurrentIter>::Item

Source§

type Iterable<'i> = &'i X where Self: 'i