Fix clippy lints

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-03-11 03:41:38 +05:30
parent b922aa32a5
commit a834366887
No known key found for this signature in database
GPG Key ID: 366D7BBAD1031E80

View File

@ -11,15 +11,13 @@ pub(crate) fn file_name_to_label(msg: String) -> String {
} }
pub(crate) fn get_search_results(items: Vec<String>, search_term: &str) -> Vec<String> { pub(crate) fn get_search_results(items: Vec<String>, search_term: &str) -> Vec<String> {
if search_term.contains("_") { if search_term.contains('_') {
items items
.clone()
.into_iter() .into_iter()
.filter(|x| x.starts_with(&search_term)) .filter(|x| x.starts_with(&search_term))
.collect() .collect()
} else { } else {
items items
.clone()
.into_iter() .into_iter()
.filter(|x| tokenized_search(x.to_string(), &search_term)) .filter(|x| tokenized_search(x.to_string(), &search_term))
.collect() .collect()
@ -101,7 +99,7 @@ mod tests {
file_name_to_label("John_Doe_1.jpg".to_string()), file_name_to_label("John_Doe_1.jpg".to_string()),
"John Doe 1".to_string() "John Doe 1".to_string()
); );
assert!(!file_name_to_label("Jane_Doe.jpg".to_string()).contains("_")) assert!(!file_name_to_label("Jane_Doe.jpg".to_string()).contains('_'))
} }
#[test] #[test]