mirror of
https://github.com/jht5945/finding.git
synced 2025-12-29 14:10:05 +08:00
use iter any
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -143,8 +143,8 @@ fn find_text_files(options: &Options, dir_path: &Path) {
|
|||||||
if options.ignore_case {
|
if options.ignore_case {
|
||||||
print_message(MessageType::WARN, "Using ignore case mode, highlight print is disabled.");
|
print_message(MessageType::WARN, "Using ignore case mode, highlight print is disabled.");
|
||||||
}
|
}
|
||||||
let file_exts = match options.file_ext.as_str() {
|
let file_exts = match &options.file_ext {
|
||||||
"" => vec![],
|
ext if ext.is_empty() => vec![],
|
||||||
ext => ext.split(',').map(|s| s.trim()).filter(|s| !s.is_empty()).map(|s| ".".to_owned() + s).collect(),
|
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);
|
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,
|
Some(s) => s, None => return,
|
||||||
};
|
};
|
||||||
if !file_exts.is_empty() {
|
if !file_exts.is_empty() {
|
||||||
let mut file_ext_matches = false;
|
if !file_exts.iter().any(|file_ext| p_str.to_lowercase().ends_with(file_ext)) {
|
||||||
for file_ext in &file_exts {
|
|
||||||
if p_str.to_lowercase().ends_with(file_ext) {
|
|
||||||
file_ext_matches = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !file_ext_matches {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user