Add a code for performing the actual search
This commit is contained in:
parent
1a18cdbf52
commit
e9e4c403e6
1 changed files with 9 additions and 1 deletions
|
@ -25,7 +25,15 @@ pub fn run(config: Config) -> Result<(), Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
|
pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
|
||||||
vec![]
|
let mut results = Vec::new();
|
||||||
|
|
||||||
|
for line in contents.lines() {
|
||||||
|
if line.contains(query) {
|
||||||
|
results.push(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
results
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in a new issue