add flat_map_iter to maybe_rayon & feature-gate it

This commit is contained in:
Sladuca 2022-09-06 14:55:51 -04:00
parent d5fbcae3f8
commit f496711b21

View File

@ -1,6 +1,6 @@
#[cfg(not(feature = "parallel"))]
use std::{
iter::{IntoIterator, Iterator},
iter::{IntoIterator, Iterator, FlatMap},
slice::{Chunks, ChunksExact, ChunksExactMut, ChunksMut},
};
@ -223,13 +223,22 @@ impl<T: Send> MaybeParChunksMut<T> for [T] {
}
}
#[cfg(not(feature = "parallel"))]
pub trait ParallelIteratorMock {
type Item;
fn find_any<P>(self, predicate: P) -> Option<Self::Item>
where
P: Fn(&Self::Item) -> bool + Sync + Send;
fn flat_map_iter<U, F>(self, map_op: F) -> FlatMap<Self, U, F>
where
Self: Sized,
U: IntoIterator,
F: Fn(Self::Item) -> U;
}
#[cfg(not(feature = "parallel"))]
impl<T: Iterator> ParallelIteratorMock for T {
type Item = T::Item;
@ -239,6 +248,15 @@ impl<T: Iterator> ParallelIteratorMock for T {
{
self.find(predicate)
}
fn flat_map_iter<U, F>(self, map_op: F) -> FlatMap<Self, U, F>
where
Self: Sized,
U: IntoIterator,
F: Fn(Self::Item) -> U
{
self.flat_map(map_op)
}
}
#[cfg(feature = "parallel")]