on master help sign in
Do not take optional as argument
2ad1848sharkdp
src/bin/bat/app.rs+8−10
@@ -260,17 +260,15 @@ impl App {
260
260
261 let mut file_input = Vec::new();
261 let mut file_input = Vec::new();
262 for (input, name) in files_or_none.zip(filenames_or_none) {
262 for (input, name) in files_or_none.zip(filenames_or_none) {
263− match input {
264− Some(input) => {
263+ if let Some(input) = input {
265− if input.to_str().unwrap() == "-" {
264+ if input.to_str().unwrap() == "-" {
266− file_input.push(InputFile::StdIn(name));
265+ file_input.push(InputFile::StdIn(name));
267− } else {
266+ } else {
267+ let ofile = name.map_or(OrdinaryFile::from_path(input), |n| {
268+ OrdinaryFile::from_path_with_name(input, n)
269+ });
268− file_input.push(InputFile::Ordinary(OrdinaryFile::from_path_with_name(
270+ file_input.push(InputFile::Ordinary(ofile))
269− input, name,
270− )))
271− }
272 }
271 }
273− None => {}
274 }
272 }
275 }
273 }
276 return Ok(file_input);
274 return Ok(file_input);
src/inputfile.rs+2−5
@@ -66,13 +66,10 @@ impl<'a> OrdinaryFile<'a> {
66 }
66 }
67 }
67 }
68
68
69− pub fn from_path_with_name(
69+ pub fn from_path_with_name(path: &'a OsStr, user_provided_name: &'a OsStr) -> OrdinaryFile<'a> {
70− path: &'a OsStr,
71− user_provided_name: Option<&'a OsStr>,
72− ) -> OrdinaryFile<'a> {
73 OrdinaryFile {
70 OrdinaryFile {
74 path,
71 path,
75− user_provided_name,
72+ user_provided_name: Some(user_provided_name),
76 }
73 }
77 }
74 }
78
75