1
0
mirror of https://github.com/jht5945/finding.git synced 2025-12-27 13:20:03 +08:00

use iter any

This commit is contained in:
2020-04-28 00:38:05 +08:00
parent 6b7c2b3759
commit 93d39ecd50

View File

@@ -143,8 +143,8 @@ fn find_text_files(options: &Options, dir_path: &Path) {
if options.ignore_case {
print_message(MessageType::WARN, "Using ignore case mode, highlight print is disabled.");
}
let file_exts = match options.file_ext.as_str() {
"" => vec![],
let file_exts = match &options.file_ext {
ext if ext.is_empty() => vec![],
ext => ext.split(',').map(|s| s.trim()).filter(|s| !s.is_empty()).map(|s| ".".to_owned() + s).collect(),
};
let total_file_count_cell = RefCell::new(0u64);
@@ -158,14 +158,7 @@ fn find_text_files(options: &Options, dir_path: &Path) {
Some(s) => s, None => return,
};
if !file_exts.is_empty() {
let mut file_ext_matches = false;
for file_ext in &file_exts {
if p_str.to_lowercase().ends_with(file_ext) {
file_ext_matches = true;
break;
}
}
if !file_ext_matches {
if !file_exts.iter().any(|file_ext| p_str.to_lowercase().ends_with(file_ext)) {
return;
}
}