diff options
Diffstat (limited to 'src/parse.rs')
-rw-r--r-- | src/parse.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/parse.rs b/src/parse.rs index 7e6cab7..1219484 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -106,17 +106,19 @@ pub fn digit_grid(lines: impl Iterator<Item = String>) -> Grid<u8> { // false positive, doing its suggestion gives borrow checker errors #[allow(clippy::redundant_closure)] -pub fn grid<F, T>(lines: impl Iterator<Item = String>, f: F) -> Grid<T> +pub fn grid<F, T>(lines: impl Iterator<Item = String>, mut f: F) -> Grid<T> where - F: Fn(u8) -> T, + F: FnMut(u8, Row, Col) -> T, T: Clone + Default + Eq + PartialEq, { lines - .map(|s| { + .enumerate() + .map(|(row, s)| { s.as_bytes() .iter() .copied() - .map(|b| f(b)) + .enumerate() + .map(|(col, b)| f(b, Row(row), Col(col))) .collect::<Vec<_>>() }) .collect() |