~irimi1/learning-rust

b663e1a3dbb6640efb3f66fe630a63e690d5ea30 — Manuel Groß 2 years ago 4a0af9c
minigrep: Implement search function
1 files changed, 9 insertions(+), 1 deletions(-)

M projects/minigrep/src/lib.rs
M projects/minigrep/src/lib.rs => projects/minigrep/src/lib.rs +9 -1
@@ 8,7 8,15 @@ pub fn run(config: Config) -> Result<(), Box<dyn Error>> {
}

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
}

pub struct Config {