aoclib::input

Function parse_newline_sep

source
pub fn parse_newline_sep<'a, T>(
    path: &'a Path,
) -> Result<impl 'a + Iterator<Item = T>>
where T: 'a + FromStr, <T as FromStr>::Err: Display,
Expand description

Parse the file at the specified path into a stream of T.

Lines are batched into clusters separated by blank lines. Once a cluster has been collected, it (and internal newlines) are parsed into a T instance.

As whitespace is potentially significant, it is not adjusted in any way before being handed to the parser.

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

See also parse_newline_sep_str for equivalent functionality for strings, useful for test data.