aoclib::input

Function parse_reader

source
pub fn parse_reader<'a, T, Reader, Filename>(
    reader: Reader,
    file_name: Filename,
) -> Result<impl 'a + Iterator<Item = T>>
where T: FromStr, <T as FromStr>::Err: Display, Reader: 'a + BufRead, Filename: 'a + Display,
Expand description

Parse the contents of the provided reader into a stream of T.

Often parse or parse_str are more ergonomic.

Each line is treated as a separate record. Leading and trailing spaces are trimmed before being handed to the parser.

If any record cannot be parsed, this prints the parse error on stderr and stops iteration.

The file name can technically be anything which is 'a + Display, but it’s used within error messages as the file name, so it should be reasonably interprable as such.