-
-
Save matklad/612f7c6142e0b27030711e6047cb55fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Option<T> { Some(T), None } | |
fn try_reduce_with<PI, R, T>(pi: PI, reduce_op: R) -> Option<T> | |
where | |
PI: ParallelIterator<Item = T>, | |
R: Fn(T::Ok, T::Ok) -> T + Sync, | |
T: Try + Send, | |
{ | |
let full = AtomicBool::new(false); | |
let consumer = TryReduceWithConsumer { | |
reduce_op: &reduce_op, | |
full: &full, | |
}; | |
pi.drive_unindexed(consumer) | |
} | |
struct TryReduceWithConsumer<'r, R: 'r> { | |
reduce_op: &'r R, | |
full: &'r AtomicBool, | |
} | |
pub trait ParallelIterator: Sized + Send { | |
type Item: Send; | |
fn drive_unindexed<C>(self, consumer: C) -> C::Result | |
where | |
C: UnindexedConsumer<Self::Item>; | |
} | |
pub trait Try { | |
type Ok; | |
type Error; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment