Skip to content

Instantly share code, notes, and snippets.

@tailhook
Created May 18, 2016 09:50
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 tailhook/d6f9ed25fc1f4dd4af98c7eb1dddeaf7 to your computer and use it in GitHub Desktop.
Save tailhook/d6f9ed25fc1f4dd4af98c7eb1dddeaf7 to your computer and use it in GitHub Desktop.
pub struct Context<X, E>(pub X, pub E);
impl<T, E> ResultExt<T, E> for Result<T, E> {
fn context<X>(self, x: X) -> Result<T, Context<X, E>> {
self.map_err(|e| Context(x, e))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment