Skip to content

Instantly share code, notes, and snippets.

@djg
Created January 19, 2018 06:50
Show Gist options
  • Save djg/acc3c4c34db9b4578c03713574719aa7 to your computer and use it in GitHub Desktop.
Save djg/acc3c4c34db9b4578c03713574719aa7 to your computer and use it in GitHub Desktop.
Rust future/result and_then style control flow.
open_server_stream().ok()
.and_then(|stream| UnixStream::from_stream(stream, &handle).ok())
.and_then(|stream| bind_and_send_client(stream, &handle, &tx_rpc))
.ok_or_else(|| io::Error::new(
io::ErrorKind::Other,
"Failed to open stream and create rpc."
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment