mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-27 05:40:32 +01:00
Merge owned and non-owned grids
Through the power of generics. Should've been easier if it was possible to be generic over mutable and non-mutable, but AsRef/AsMut is close enough
This commit is contained in:
@@ -15,7 +15,7 @@ impl Symmetry {
|
||||
}
|
||||
}
|
||||
|
||||
fn find_symmetry(grid: Grid<'_>, differences: usize) -> Option<Symmetry> {
|
||||
fn find_symmetry(grid: Grid<&[u8]>, differences: usize) -> Option<Symmetry> {
|
||||
// Attempt to find a vertical line of reflection first
|
||||
for c in 1..grid.width() {
|
||||
if grid
|
||||
@@ -48,7 +48,7 @@ fn find_symmetry(grid: Grid<'_>, differences: usize) -> Option<Symmetry> {
|
||||
None
|
||||
}
|
||||
|
||||
fn parse_grids(input: &[u8]) -> anyhow::Result<Vec<Grid<'_>>> {
|
||||
fn parse_grids(input: &[u8]) -> anyhow::Result<Vec<Grid<&[u8]>>> {
|
||||
let mut result = Vec::new();
|
||||
let mut start = 0;
|
||||
let mut last_newline = 0;
|
||||
|
||||
Reference in New Issue
Block a user