Skip to content

Instantly share code, notes, and snippets.

@tailhook
Last active May 18, 2016 09:31
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/935b874a9257d6fa4b678b5fbe73ece6 to your computer and use it in GitHub Desktop.
Save tailhook/935b874a9257d6fa4b678b5fbe73ece6 to your computer and use it in GitHub Desktop.
enum Error {
Io(io::Error),
Parse(ParseIntError),
}
// ...
try!(File::open(fname)
.and_then(|mut f| f.read_to_string(&mut buf))
.map_err(|e| Error::Io(e, fname.to_path_buf())));
let x: u64 = try!(buf.parse()
.map_err(|e| Error::Parse(e, fname.to_path_buf())));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment