Skip to content

Instantly share code, notes, and snippets.

Created February 24, 2017 08:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/55afc2eb522a54def8dec7ba2e33e6c8 to your computer and use it in GitHub Desktop.
Save anonymous/55afc2eb522a54def8dec7ba2e33e6c8 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
use std::error::Error;
use std::str::FromStr;
fn main() {
let s = "r5";
let x = i32::from_str(s).map_err(foo);
x.map_err(|v| println!("{}", v.description()));
}
fn foo<'a, A>(a: A) -> Box<Error + 'a>
where A: Error + 'a
{
Box::new(a)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment