grrs-masterbongo 0.1.0

A simple implementation of grep
Documentation
/// Instead of printing, write to Writer so its now testable
#[allow(unused_must_use)]
pub fn find_matches(content: &str, pattern: &str, mut writer: impl std::io::Write) {
    // wrtier is whatever that implements std::io::Write
    for line in content.lines() {
        if line.contains(pattern) {
            writeln!(writer, "{}", line);
        }
    }
}

#[cfg(test)]
mod tests {
    use crate::find_matches;

    #[test]
    fn find_a_match() {
        // Vec<u8> can grow dynamically and implements std::io::Write
        let mut result = Vec::new();
        find_matches("test\nnot", "test", &mut result);
        assert_eq!(result, b"test\n");
    }
}