diff options
Diffstat (limited to 'rust-cli/grrs/src/lib.rs')
| -rw-r--r-- | rust-cli/grrs/src/lib.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/rust-cli/grrs/src/lib.rs b/rust-cli/grrs/src/lib.rs new file mode 100644 index 0000000..f91064f --- /dev/null +++ b/rust-cli/grrs/src/lib.rs @@ -0,0 +1,13 @@ +use std::{io::{BufReader, BufRead, Error}, fs::File}; + +pub fn find_matches(file: &File, pattern: &str) -> Result<Vec<String>, Error> { + let reader = BufReader::new(file); + let mut result = Vec::<String>::new(); + for line in reader.lines() { + let line_val = line.unwrap(); + if line_val.contains(&pattern) { + result.push(line_val); + } + } + return Ok(result); +}
\ No newline at end of file |
