Skip to content

Instantly share code, notes, and snippets.

@martinmroz
Created October 27, 2019 02:39
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 martinmroz/0cc0224ca24541edf176e67ba38e9f20 to your computer and use it in GitHub Desktop.
Save martinmroz/0cc0224ca24541edf176e67ba38e9f20 to your computer and use it in GitHub Desktop.
Parallelized version of our counter.
/// Computes the flux over the provided input byte string.
fn flux_over_byte_string<T>(input: T) -> Option<Flux>
where
T: AsRef<[u8]> {
input.as_ref()
.par_iter()
.cloned()
.map(Flux::from)
.fold(|| None, |acc, next| span_opt(acc, Some(next)))
.reduce(|| None, |acc, next| span_opt(acc, next))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment