Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
improves search function
Browse files Browse the repository at this point in the history
  • Loading branch information
brenomfviana committed Apr 16, 2020
1 parent e16f7ec commit 7fad4ac
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,7 @@ impl Config {
/// Searches for the query string in the file content and returns list of the
/// found lines.
pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
// Init list of found lines with the query string
let mut results = Vec::new();
// Look for the lines that contains the query string
for line in contents.lines() {
if line.contains(query) {
results.push(line)
}
}
// Return result
results
contents.lines().filter(|line| line.contains(query)).collect()
}

/// Converts all characters to lowercase, searches for the query string in the
Expand Down

0 comments on commit 7fad4ac

Please sign in to comment.