1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-01-19 04:21:06 +00:00

Do not take optional as argument

This commit is contained in:
sharkdp 2020-04-11 19:23:32 +02:00 committed by David Peter
parent 90e7d2fe33
commit 2ad1848859
2 changed files with 10 additions and 15 deletions

View File

@ -260,18 +260,16 @@ impl App {
let mut file_input = Vec::new(); let mut file_input = Vec::new();
for (input, name) in files_or_none.zip(filenames_or_none) { for (input, name) in files_or_none.zip(filenames_or_none) {
match input { if let Some(input) = input {
Some(input) => {
if input.to_str().unwrap() == "-" { if input.to_str().unwrap() == "-" {
file_input.push(InputFile::StdIn(name)); file_input.push(InputFile::StdIn(name));
} else { } else {
file_input.push(InputFile::Ordinary(OrdinaryFile::from_path_with_name( let ofile = name.map_or(OrdinaryFile::from_path(input), |n| {
input, name, OrdinaryFile::from_path_with_name(input, n)
))) });
file_input.push(InputFile::Ordinary(ofile))
} }
} }
None => {}
}
} }
return Ok(file_input); return Ok(file_input);
} }

View File

@ -66,13 +66,10 @@ impl<'a> OrdinaryFile<'a> {
} }
} }
pub fn from_path_with_name( pub fn from_path_with_name(path: &'a OsStr, user_provided_name: &'a OsStr) -> OrdinaryFile<'a> {
path: &'a OsStr,
user_provided_name: Option<&'a OsStr>,
) -> OrdinaryFile<'a> {
OrdinaryFile { OrdinaryFile {
path, path,
user_provided_name, user_provided_name: Some(user_provided_name),
} }
} }