Skip to content

Instantly share code, notes, and snippets.

@adamreid
Created October 13, 2014 15:54
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 adamreid/9cbc5b3575ba73e75aa2 to your computer and use it in GitHub Desktop.
Save adamreid/9cbc5b3575ba73e75aa2 to your computer and use it in GitHub Desktop.
use std::io;
use std::io::{fs, FileType};
fn main() {
match fs::stat(&Path::new(".")) {
Ok(stat) => println!("{}", ft_display_str(&stat.kind)),
Err(e) => println!("Could not stat .: {}", e),
};
}
fn ft_display_str(ft: &FileType) -> &'static str {
match ft {
TypeFile => "regular file",
TypeDirectory => "directory",
TypeNamedPipe => "fifo",
TypeBlockSpecial => "block special file",
TypeSymlink => "symbolic link",
TypeUnknown => "unknown",
}
}
main.rs:14:9: 14:22 error: unreachable pattern [E0001] (pass `--explain E0001` to see a detailed explanation)
main.rs:14 TypeDirectory => "directory",
^~~~~~~~~~~~~
main.rs:15:9: 15:22 error: unreachable pattern [E0001] (pass `--explain E0001` to see a detailed explanation)
main.rs:15 TypeNamedPipe => "fifo",
^~~~~~~~~~~~~
main.rs:16:9: 16:25 error: unreachable pattern [E0001] (pass `--explain E0001` to see a detailed explanation)
main.rs:16 TypeBlockSpecial => "block special file",
^~~~~~~~~~~~~~~~
main.rs:17:9: 17:20 error: unreachable pattern [E0001] (pass `--explain E0001` to see a detailed explanation)
main.rs:17 TypeSymlink => "symbolic link",
^~~~~~~~~~~
main.rs:18:9: 18:20 error: unreachable pattern [E0001] (pass `--explain E0001` to see a detailed explanation)
main.rs:18 TypeUnknown => "unknown",
^~~~~~~~~~~
error: aborting due to 5 previous errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment