aoclib::input

Function parse_two_phase_reader

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

Parse the contents of the provided reader into a single instance of A and a stream of B.

Often parse_two_phase or parse_two_phase_str are more ergonomic.

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

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.