Skip to content

Instantly share code, notes, and snippets.

Created May 15, 2016 16:50
Show Gist options
  • Save anonymous/7cf48f69f2571989d4031e652471cb12 to your computer and use it in GitHub Desktop.
Save anonymous/7cf48f69f2571989d4031e652471cb12 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
use std::io::prelude::*;
use std::fs::File;
use std::io::{ Error, ErrorKind };
fn open_file(path: &str) -> Vec<u8> {
let mut f = match File::open( path ) {
Ok(x) => x,
Err(e) => match e.kind() {
ErrorKind::NotFound => /*idk what you want to do*/,
ErrorKind::PermissionDenied => /*but I think you get the idea*/,
ErrorKind::ConnectionRefused => /*at least I hope*/,
ErrorKind::ConnectionReset => /*because I'm not doing all*/,
....
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment