Skip to content

Instantly share code, notes, and snippets.

@lu-zero
Created February 2, 2022 16:15
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 lu-zero/a10d3da55a006d291c9d2019058d0236 to your computer and use it in GitHub Desktop.
Save lu-zero/a10d3da55a006d291c9d2019058d0236 to your computer and use it in GitHub Desktop.
enum Error<T> {
..
Again(T),
}
fn send<T: AsRef<[u8]>>(buf: T, ...) -> Result<(), Error<T>> { ... }
let mut buf = ...;
loop {
match send(buf, ...) {
Ok(()) => buf = get_new_buf(),
Err(Error::Again(b)) => buf = b,
Err(e) => return Err(e),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment