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

fix clipy

This commit is contained in:
2020-01-11 11:34:09 +08:00
parent 5c628ff68a
commit 1d079d1d88

View File

@@ -139,7 +139,7 @@ fn match_lines(tag: &str, content: &String, options: &Options) -> bool {
} }
let mut matches_any = false; let mut matches_any = false;
if match_lines_vec.len() > 0 { if !match_lines_vec.is_empty() {
print_lastline(""); print_lastline("");
print_message(MessageType::OK, &format!("Find in {}:", tag)); print_message(MessageType::OK, &format!("Find in {}:", tag));
for i in 0..match_lines_vec.len() { for i in 0..match_lines_vec.len() {
@@ -164,7 +164,7 @@ fn match_lines(tag: &str, content: &String, options: &Options) -> bool {
} }
fn find_text_files(options: &Options, dir_path: &Path) { fn find_text_files(options: &Options, dir_path: &Path) {
if options.search_text.len() < 1 { if options.search_text.is_empty() {
print_message(MessageType::ERROR, "Param search_text cannot be empty."); print_message(MessageType::ERROR, "Param search_text cannot be empty.");
return; return;
} }
@@ -174,7 +174,7 @@ fn find_text_files(options: &Options, dir_path: &Path) {
let file_exts = match options.file_ext.as_str() { let file_exts = match options.file_ext.as_str() {
"" => vec![], "" => vec![],
ext => { ext => {
ext.split(",").map(|s| s.trim()).filter(|s| s.len() > 0).map(|s| String::from(".") + s).collect() ext.split(',').map(|s| s.trim()).filter(|s| !s.is_empty()).map(|s| String::from(".") + s).collect()
}, },
}; };
let total_file_count_cell = RefCell::new(0u64); let total_file_count_cell = RefCell::new(0u64);
@@ -188,7 +188,7 @@ fn find_text_files(options: &Options, dir_path: &Path) {
None => return, None => return,
Some(s) => s, Some(s) => s,
}; };
if file_exts.len() > 0 { if !file_exts.is_empty() {
let mut file_ext_matches = false; let mut file_ext_matches = false;
for i in 0..file_exts.len() { for i in 0..file_exts.len() {
if p_str.to_lowercase().ends_with(&file_exts[i]) { if p_str.to_lowercase().ends_with(&file_exts[i]) {
@@ -200,7 +200,7 @@ fn find_text_files(options: &Options, dir_path: &Path) {
return; return;
} }
} }
if options.filter_file_name.len() > 0 { if !options.filter_file_name.is_empty() {
if ! p_str.contains(options.filter_file_name.as_str()) { if ! p_str.contains(options.filter_file_name.as_str()) {
return; return;
} }