Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@matklad

matklad/repro.rs Secret

Last active October 24, 2019 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matklad/612f7c6142e0b27030711e6047cb55fc to your computer and use it in GitHub Desktop.
Save matklad/612f7c6142e0b27030711e6047cb55fc to your computer and use it in GitHub Desktop.
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