From 0dbc07cc94f884814f728034e6da67adf7b5530c Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Thu, 26 Dec 2024 11:34:13 -0800 Subject: [PATCH] tidy the parser --- day06/src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/day06/src/main.rs b/day06/src/main.rs index f0f1e0b..2fbe21d 100644 --- a/day06/src/main.rs +++ b/day06/src/main.rs @@ -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 { let mut gdir = Dir::N; let mut loc = Loc(0, 0); - let mut input = input; - let cells: Vec> = separated(1.., parse_line, newline) - .parse_next(&mut input) - .unwrap(); + let (cells, _): (Vec>, _) = + 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() {