Skip to content
Myr

Refactor to for-loop

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by DJRHails · committed by David Peter · parent fef1b91 · Browse files · 1 file+19 added−24 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+19 added−24 removed

  • other:+19 added−24 removed

1 file+19 added−24 removed

modified:src/main.rs+19 added-24 removed
73 unmodified lines
74 .transpose()?75 .unwrap_or("");7677 // Get one or more root directories to search.78 let mut dir_vec: Vec<_> = match matches78 let passed_arguments = matches79 .values_of_os("path")80 .or_else(|| matches.values_of_os("search-path"))81 {82 Some(paths) => paths83 .map(|path| {84 let path_buffer = PathBuf::from(path);85 if filesystem::is_dir(&path_buffer) {86 Ok(path_buffer)87 } else {88 Err(anyhow!(89 "Search path '{}' is not a directory.",90 path_buffer.to_string_lossy()91 ))92 }93 })94 .inspect(|res| {95 if let Err(e) = res {96 print_error(format!("{}", e))97 }98 })99 .filter_map(Result::ok)100 .collect::<Vec<_>>(),101 None => vec![current_directory.to_path_buf()],102 };80 .or_else(|| matches.values_of_os("search-path"));8182 // Assign current directory to search vector.83 let mut dir_vec: Vec<_> = vec![current_directory.to_path_buf()];8485 // Assign any valid arguments to search vector.86 if let Some(paths) = passed_arguments {87 dir_vec = vec![];88 for path in paths {89 let path_buffer = PathBuf::from(path);90 if filesystem::is_dir(&path_buffer) {91 dir_vec.push(path_buffer);92 }93 else {94 print_error(format!("Search path '{}' is not a directory.", path_buffer.to_string_lossy()));95 }96 }97 }9899 if matches.is_present("absolute-path") {100 dir_vec = dir_vec101 .iter()102 .map(|path_buffer| {
317 unmodified lines