chap_grrs/
lib.rs

1use std::io::BufRead;
2
3pub fn find_and_print_matches(line: &mut String, pattern: &str,
4                              reader: &mut std::io::BufReader<std::fs::File>,
5                              mut writer: impl std::io::Write) {
6    loop {
7        line.clear();
8
9        let bytes_read = reader.read_line(line).expect("could not read line");
10
11        if bytes_read == 0 {
12            break;
13        }
14
15        if line.contains(pattern) {
16            writeln!(writer, "{}", line).expect("");
17        }
18    }
19}