Skip to content

Instantly share code, notes, and snippets.

@mnemnion
Created March 14, 2017 23:07
Show Gist options
  • Save mnemnion/805df6023e93bc6180fac67191f24ec1 to your computer and use it in GitHub Desktop.
Save mnemnion/805df6023e93bc6180fac67191f24ec1 to your computer and use it in GitHub Desktop.
// instead of having to do this all the time:
let maybe_utf8 = match stream.fill_buf() {
Ok(filehandle) => filehandle,
Err(_) => return captures,
};
let phrase = match from_utf8(maybe_utf8) {
Ok(utf8) => String::from(utf8),
Err(_) => return captures,
};
// why not this?
let buffer= presuming!(stream.fill_buff(), handle_file_access);
let phrase = presuming!(from_utf8(buffer), handle_utf8_conversion);
// then at the bottom
// This is the tricky part, and the below isn't very good.
fn handle_file_access() -> /* something goes here */ {
}
fn handle_utf8_conversion() -> {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment