Created
February 24, 2017 08:11
-
-
Save anonymous/55afc2eb522a54def8dec7ba2e33e6c8 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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