From 4ff360669f248af31d7bcc8b9c995f90c4e56f93 Mon Sep 17 00:00:00 2001 From: ufuji1984 Date: Wed, 12 Dec 2018 05:55:11 +0900 Subject: [PATCH] add quotes around filename and make it more concise by using map_err --- src/inputfile.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/inputfile.rs b/src/inputfile.rs index 2555656f..eae9c713 100644 --- a/src/inputfile.rs +++ b/src/inputfile.rs @@ -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());