tidy the parser

This commit is contained in:
Joe Ardent 2024-12-26 11:34:13 -08:00
parent 53816fed73
commit 0dbc07cc94

View file

@ -6,7 +6,7 @@ use std::{
use winnow::{
PResult, Parser,
ascii::{newline, till_line_ending},
combinator::{alt, repeat, separated},
combinator::{alt, opt, repeat, separated},
};
fn main() {
@ -230,10 +230,10 @@ fn parse(input: &str) -> PResult<Board> {
let mut gdir = Dir::N;
let mut loc = Loc(0, 0);
let mut input = input;
let cells: Vec<Vec<Cell>> = separated(1.., parse_line, newline)
.parse_next(&mut input)
.unwrap();
let (cells, _): (Vec<Vec<Cell>>, _) =
winnow::combinator::seq!(separated(1.., parse_line, newline), opt(newline))
.parse(input)
.unwrap();
for (row, line) in cells.iter().enumerate() {
for (col, cell) in line.iter().enumerate() {