Function aoc_parse::prelude::section

source ·
pub fn section<P>(parser: P) -> RegionParser<Section, P>
Expand description

section(pattern) matches zero or more nonblank lines, followed by either a blank line or the end of input. The nonblank lines must match pattern.

section() consumes the blank line. pattern should not expect to see it.

It’s common for an AoC puzzle input to have several lines of data, then a blank line, and then a different kind of data. You can parse this with section(p1) section(p2).

section(lines(u64)) matches a section that’s a list of numbers, one per line.

Examples found in repository?
src/parsers/lines.rs (line 243)
242
243
244
pub fn sections<P>(parser: P) -> RepeatParser<SectionParser<P>, EmptyParser> {
    star(section(parser))
}