ParMapResult

Struct ParMapResult 

Source
pub struct ParMapResult<I, T, E, O, M1, R = RunnerWithPool<SequentialPool>>
where R: ParallelRunner, I: ConcurrentIter, O: IntoResult<T, E>, M1: Fn(<I as ConcurrentIter>::Item) -> O + Sync,
{ /* private fields */ }
Expand description

A parallel iterator for which the computation either completely succeeds, or fails and early exits with an error.

Trait Implementationsยง

Sourceยง

impl<I, T, E, O, M1, R> ParIterResult<R> for ParMapResult<I, T, E, O, M1, R>
where R: ParallelRunner, I: ConcurrentIter, O: IntoResult<T, E>, M1: Fn(<I as ConcurrentIter>::Item) -> O + Sync,

Sourceยง

type Item = T

Type of the Ok element, to be received as the Ok variant iff the entire computation succeeds.
Sourceยง

type Err = E

Type of the Err element, to be received if any of the computations fails.
Sourceยง

type RegularItem = O

Element type of the regular parallel iterator this fallible iterator can be converted to, simply Result<Self::Ok, Self::Err>.
Sourceยง

type RegularParIter = ParMap<I, O, M1, R>

Regular parallel iterator this fallible iterator can be converted into.
Sourceยง

fn con_iter_len(&self) -> Option<usize>

Returns a reference to the input concurrent iterator.
Sourceยง

fn into_regular_par( self, ) -> <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::RegularParIter

Converts this fallible iterator into a regular parallel iterator; i.e., ParIter, with Item = Result<Self::Ok, Self::Err>.
Sourceยง

fn from_regular_par( regular_par: <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::RegularParIter, ) -> ParMapResult<I, T, E, O, M1, R>

Converts the regular_par iterator with Item = Result<Self::Ok, Self::Err> into fallible result iterator.
Sourceยง

fn with_runner<Q>( self, orchestrator: Q, ) -> impl ParIterResult<Q, Item = <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Item, Err = <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Err>
where Q: ParallelRunner,

Rather than the DefaultRunner, uses the parallel runner Q which implements ParallelRunner. Read more
Sourceยง

fn collect_into<C>( self, output: C, ) -> Result<C, <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Err>
where C: ParCollectInto<<ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Item>, <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Item: Send, <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Err: Send,

Collects all the items from an iterator into a collection iff all elements are of Ok variant. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn reduce<Reduce>( self, reduce: Reduce, ) -> Result<Option<<ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Item>, <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Err>
where <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Item: Send, <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Err: Send, Reduce: Fn(<ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Item, <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Item) -> <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Item + Sync,

Reduces the elements to a single one, by repeatedly applying a reducing operation. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn first( self, ) -> Result<Option<<ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Item>, <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Err>
where <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Item: Send, <ParMapResult<I, T, E, O, M1, R> as ParIterResult<R>>::Err: Send,

Returns the first (or any) element of the iterator. If the iterator is empty, Ok(None) is returned. Early exits and returns the error if an Err element is observed first. Read more
Sourceยง

fn num_threads(self, num_threads: impl Into<NumThreads>) -> Self
where Self: Sized,

Sets the number of threads to be used in the parallel execution. Integers can be used as the argument with the following mapping: Read more
Sourceยง

fn chunk_size(self, chunk_size: impl Into<ChunkSize>) -> Self
where Self: Sized,

Sets the number of elements to be pulled from the concurrent iterator during the parallel execution. When integers are used as argument, the following mapping applies: Read more
Sourceยง

fn iteration_order(self, order: IterationOrder) -> Self
where Self: Sized,

Sets the iteration order of the parallel computation. Read more
Sourceยง

fn with_pool<P>( self, pool: P, ) -> impl ParIterResult<RunnerWithPool<P, <R as ParallelRunner>::Executor>, Item = Self::Item, Err = Self::Err>
where P: ParThreadPool, Self: Sized,

Rather than DefaultPool, uses the parallel runner with the given pool implementing ParThreadPool. Read more
Sourceยง

fn map<Out, Map>( self, map: Map, ) -> impl ParIterResult<R, Item = Out, Err = Self::Err>
where Self: Sized, Map: Fn(Self::Item) -> Out + Sync + Clone, Out: Send,

Takes a closure map and creates a parallel iterator which calls that closure on each element. Read more
Sourceยง

fn filter<Filter>( self, filter: Filter, ) -> impl ParIterResult<R, Item = Self::Item, Err = Self::Err>
where Self: Sized, Filter: Fn(&Self::Item) -> bool + Sync + Clone, Self::Item: Send,

Creates an iterator which uses a closure filter to determine if an element should be yielded. Read more
Sourceยง

fn flat_map<IOut, FlatMap>( self, flat_map: FlatMap, ) -> impl ParIterResult<R, Item = <IOut as IntoIterator>::Item, Err = Self::Err>
where Self: Sized, IOut: IntoIterator, <IOut as IntoIterator>::Item: Send, FlatMap: Fn(Self::Item) -> IOut + Sync + Clone,

Creates an iterator that works like map, but flattens nested structure. Read more
Sourceยง

fn filter_map<Out, FilterMap>( self, filter_map: FilterMap, ) -> impl ParIterResult<R, Item = Out, Err = Self::Err>
where Self: Sized, FilterMap: Fn(Self::Item) -> Option<Out> + Sync + Clone, Out: Send,

Creates an iterator that both filters and maps. Read more
Sourceยง

fn inspect<Operation>( self, operation: Operation, ) -> impl ParIterResult<R, Item = Self::Item, Err = Self::Err>
where Self: Sized, Operation: Fn(&Self::Item) + Sync + Clone, Self::Item: Send,

Does something with each successful element of an iterator, passing the value on, provided that all elements are of Ok variant; short-circuits and returns the error otherwise. Read more
Sourceยง

fn collect<C>(self) -> Result<C, Self::Err>
where Self: Sized, Self::Item: Send, Self::Err: Send, C: ParCollectInto<Self::Item>,

Transforms an iterator into a collection iff all elements are of Ok variant. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn all<Predicate>(self, predicate: Predicate) -> Result<bool, Self::Err>
where Self: Sized, Self::Item: Send, Self::Err: Send, Predicate: Fn(&Self::Item) -> bool + Sync,

Tests if every element of the iterator matches a predicate. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn any<Predicate>(self, predicate: Predicate) -> Result<bool, Self::Err>
where Self: Sized, Self::Item: Send, Self::Err: Send, Predicate: Fn(&Self::Item) -> bool + Sync,

Tests if any element of the iterator matches a predicate. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn count(self) -> Result<usize, Self::Err>
where Self: Sized, Self::Err: Send,

Consumes the iterator, counting the number of iterations and returning it. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn for_each<Operation>(self, operation: Operation) -> Result<(), Self::Err>
where Self: Sized, Self::Err: Send, Operation: Fn(Self::Item) + Sync,

Calls a closure on each element of an iterator, and returns Ok(()) if all elements succeed. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn max(self) -> Result<Option<Self::Item>, Self::Err>
where Self: Sized, Self::Err: Send, Self::Item: Ord + Send,

Returns Ok of maximum element of an iterator if all elements succeed. If the iterator is empty, Ok(None) is returned. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn max_by<Compare>( self, compare: Compare, ) -> Result<Option<Self::Item>, Self::Err>
where Self: Sized, Self::Item: Send, Self::Err: Send, Compare: Fn(&Self::Item, &Self::Item) -> Ordering + Sync,

Returns the element that gives the maximum value with respect to the specified compare function. If the iterator is empty, Ok(None) is returned. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn max_by_key<Key, GetKey>( self, key: GetKey, ) -> Result<Option<Self::Item>, Self::Err>
where Self: Sized, Self::Item: Send, Self::Err: Send, Key: Ord, GetKey: Fn(&Self::Item) -> Key + Sync,

Returns the element that gives the maximum value from the specified function. If the iterator is empty, Ok(None) is returned. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn min(self) -> Result<Option<Self::Item>, Self::Err>
where Self: Sized, Self::Item: Ord + Send, Self::Err: Send,

Returns Ok of minimum element of an iterator if all elements succeed. If the iterator is empty, Ok(None) is returned. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn min_by<Compare>( self, compare: Compare, ) -> Result<Option<Self::Item>, Self::Err>
where Self: Sized, Self::Item: Send, Self::Err: Send, Compare: Fn(&Self::Item, &Self::Item) -> Ordering + Sync,

Returns the element that gives the maximum value with respect to the specified compare function. If the iterator is empty, Ok(None) is returned. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn min_by_key<Key, GetKey>( self, get_key: GetKey, ) -> Result<Option<Self::Item>, Self::Err>
where Self: Sized, Self::Item: Send, Self::Err: Send, Key: Ord, GetKey: Fn(&Self::Item) -> Key + Sync,

Returns the element that gives the minimum value from the specified function. If the iterator is empty, Ok(None) is returned. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn sum<Out>(self) -> Result<Out, Self::Err>
where Self: Sized, Self::Item: Sum<Out>, Self::Err: Send, Out: Send,

Sums the elements of an iterator. Early exits and returns the error if any of the elements is an Err. Read more
Sourceยง

fn find<Predicate>( self, predicate: Predicate, ) -> Result<Option<Self::Item>, Self::Err>
where Self: Sized, Self::Item: Send, Self::Err: Send, Predicate: Fn(&Self::Item) -> bool + Sync,

Returns the first (or any) element of the iterator that satisfies the predicate. If the iterator is empty, Ok(None) is returned. Early exits and returns the error if an Err element is observed first. Read more

Auto Trait Implementationsยง

ยง

impl<I, T, E, O, M1, R> Freeze for ParMapResult<I, T, E, O, M1, R>
where R: Freeze, I: Freeze, M1: Freeze,

ยง

impl<I, T, E, O, M1, R> RefUnwindSafe for ParMapResult<I, T, E, O, M1, R>

ยง

impl<I, T, E, O, M1, R> Send for ParMapResult<I, T, E, O, M1, R>
where T: Send, E: Send,

ยง

impl<I, T, E, O, M1, R> Sync for ParMapResult<I, T, E, O, M1, R>
where T: Sync, E: Sync,

ยง

impl<I, T, E, O, M1, R> Unpin for ParMapResult<I, T, E, O, M1, R>
where R: Unpin, I: Unpin, M1: Unpin, T: Unpin, E: Unpin,

ยง

impl<I, T, E, O, M1, R> UnwindSafe for ParMapResult<I, T, E, O, M1, R>

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> SoM<T> for T

Sourceยง

fn get_ref(&self) -> &T

Returns a reference to self.
Sourceยง

fn get_mut(&mut self) -> &mut T

Returns a mutable reference to self.
Sourceยง

impl<T> SoR<T> for T

Sourceยง

fn get_ref(&self) -> &T

Returns a reference to self.
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.