Skip to content

Instantly share code, notes, and snippets.

@martinmroz
Created October 27, 2019 02:35
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/f609cd21dc50ca1ff18727fa53325732 to your computer and use it in GitHub Desktop.
Save martinmroz/f609cd21dc50ca1ff18727fa53325732 to your computer and use it in GitHub Desktop.
A functional take on generating a span over an entire byte string
/// 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()
.iter()
.cloned()
.map(Flux::from)
.fold(None, |acc, next| span_opt(acc, Some(next)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment