Skip to content

Commit

Permalink
add quotes around filename
Browse files Browse the repository at this point in the history
and make it more concise by using map_err
  • Loading branch information
ufuji1984 authored and sharkdp committed Dec 11, 2018
1 parent 549e5d7 commit 4ff3606
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/inputfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ impl<'a> InputFile<'a> {
match self {
InputFile::StdIn => Ok(InputFileReader::new(stdin.lock())),
InputFile::Ordinary(filename) => {
let file = match File::open(filename) {
Ok(f) => f,
Err(e) => return Err(format!("{}: {}", filename, e).into()),
};
let file = File::open(filename).map_err(|e| format!("'{}': {}", filename, e))?;

if file.metadata()?.is_dir() {
return Err(format!("'{}' is a directory.", filename).into());
Expand Down

0 comments on commit 4ff3606

Please sign in to comment.