aoclib::input

Function parse_two_phase_str

source
pub fn parse_two_phase_str<'a, A, B>(
    data: &'a str,
) -> 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,
Expand description

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

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.