mbeah_grrs/lib.rs
1
2pub fn find_matches(content: &str, pattern: &str, mut writer: impl std::io::Write){
3 for line in content.lines() {
4 if line.contains(pattern) {
5 writeln!(writer, "{}", line);
6 }
7 }
8}
9
10
11#[test]
12fn test_answer() {
13 let mut result = Vec::new();
14 find_matches("foo\nbar\nbaz", "bar", &mut result);
15 assert_eq!(result, b"bar\n");
16}