mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-08 08:43:06 +00:00
add flat_map_iter to maybe_rayon & feature-gate it
This commit is contained in:
parent
d5fbcae3f8
commit
f496711b21
@ -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")]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user