[][src]Function grep_cli::patterns_from_reader

pub fn patterns_from_reader<R: Read>(rdr: R) -> Result<Vec<String>>

Read patterns from any reader, one per line.

If there was a problem reading or if any of the patterns contain invalid UTF-8, then an error is returned. If there was a problem with a specific pattern, then the error message will include the line number.

Note that this routine uses its own internal buffer, so the caller should not provide their own buffered reader if possible.

Example

This shows how to parse patterns, one per line.

use grep_cli::patterns_from_reader;

let patterns = "\
foo
bar\\s+foo
[a-z]{3}
";

assert_eq!(patterns_from_reader(patterns.as_bytes())?, vec![
    r"foo",
    r"bar\s+foo",
    r"[a-z]{3}",
]);