#[allow(unused_must_use)]
pub fn find_matches(content: &str, pattern: &str, mut writer: impl 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() {
let mut result = Vec::new();
find_matches("test\nnot", "test", &mut result);
assert_eq!(result, b"test\n");
}
}