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

fix clippy

This commit is contained in:
2020-01-11 11:43:10 +08:00
parent 1d079d1d88
commit c03ab9ff4c

View File

@@ -26,12 +26,11 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
const GIT_HASH: &str = env!("GIT_HASH"); const GIT_HASH: &str = env!("GIT_HASH");
fn print_version() { fn print_version() {
print!(r#"finding {} - {} println!(r#"finding {} - {}
Copyright (C) 2019 Hatter Jiang. Copyright (C) 2019 Hatter Jiang.
License MIT <https://opensource.org/licenses/MIT> License MIT <https://opensource.org/licenses/MIT>
Written by Hatter Jiang Written by Hatter Jiang"#, VERSION, &GIT_HASH[0..7]);
"#, VERSION, &GIT_HASH[0..7]);
} }
fn find_huge_files(options: &Options, dir_path: &Path) { fn find_huge_files(options: &Options, dir_path: &Path) {
@@ -43,10 +42,9 @@ fn find_huge_files(options: &Options, dir_path: &Path) {
match p.metadata() { match p.metadata() {
Err(err) => { Err(err) => {
if options.verbose { if options.verbose {
let p_str = p.to_str(); if let Some(p_str) = p.to_str() {
if p_str.is_some() {
print_lastline(""); print_lastline("");
print_message(MessageType::WARN, &format!("Read file {} meta failed: {}", p_str.unwrap(), err)); print_message(MessageType::WARN, &format!("Read file {} meta failed: {}", p_str, err));
} }
} }
return; return;
@@ -105,7 +103,7 @@ impl MatchLine {
} }
} }
fn match_lines(tag: &str, content: &String, options: &Options) -> bool { fn match_lines(tag: &str, content: &str, options: &Options) -> bool {
let search_text = &options.search_text; let search_text = &options.search_text;
let lines = content.lines(); let lines = content.lines();
let mut match_lines_vec = vec![]; let mut match_lines_vec = vec![];
@@ -127,7 +125,7 @@ fn match_lines(tag: &str, content: &String, options: &Options) -> bool {
false => ln.contains(the_search_text), false => ln.contains(the_search_text),
}; };
let mut matches_line_content = true; let mut matches_line_content = true;
if options.filter_line_content.len() > 0 { if !options.filter_line_content.is_empty(){
if ! ln.contains(options.filter_line_content.as_str()) { if ! ln.contains(options.filter_line_content.as_str()) {
matches_line_content = false; matches_line_content = false;
} }
@@ -190,8 +188,8 @@ fn find_text_files(options: &Options, dir_path: &Path) {
}; };
if !file_exts.is_empty() { 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 file_ext in &file_exts {
if p_str.to_lowercase().ends_with(&file_exts[i]) { if p_str.to_lowercase().ends_with(file_ext) {
file_ext_matches = true; file_ext_matches = true;
break; break;
} }