Skip to content

Commit

Permalink
remove unnecessary pubs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooster0 committed Aug 19, 2021
1 parent b27eb6a commit 84a6019
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
35 changes: 17 additions & 18 deletions src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,25 @@ pub struct Grid {
pub undo_redo_buffer: UndoRedoBuffer,
}

fn get_index(width: u16, point: Point) -> usize {
point.y as usize * width as usize + point.x as usize
fn get_index(grid_width: u16, point: Point) -> usize {
point.y as usize * grid_width as usize + point.x as usize
}

fn get_horizontal_clues(cells: &[Cell], width: u16, y: u16) -> impl Iterator<Item = Clue> + '_ {
(0..width)
.map(move |x| cells[get_index(width, Point { x, y })] == Cell::Filled)
fn get_horizontal_clues(
cells: &[Cell],
grid_width: u16,
y: u16,
) -> impl Iterator<Item = Clue> + '_ {
(0..grid_width)
.map(move |x| cells[get_index(grid_width, Point { x, y })] == Cell::Filled)
.dedup_with_count()
.filter(|(_, filled)| *filled)
.map(|(count, _)| count as Clue)
}

fn get_vertical_clues(
cells: &[Cell],
width: u16,
height: u16,
x: u16,
) -> impl Iterator<Item = Clue> + '_ {
(0..height)
.map(move |y| cells[get_index(width, Point { x, y })] == Cell::Filled)
fn get_vertical_clues(cells: &[Cell], grid_size: Size, x: u16) -> impl Iterator<Item = Clue> + '_ {
(0..grid_size.height)
.map(move |y| cells[get_index(grid_size.width, Point { x, y })] == Cell::Filled)
.dedup_with_count()
.filter(|(_, filled)| *filled)
.map(|(count, _)| count as Clue)
Expand All @@ -76,7 +75,7 @@ impl Grid {
let mut vertical_clues_solutions = Vec::<Clues>::new();
for x in 0..size.width {
let vertical_clues_solution: Clues =
get_vertical_clues(&cells, size.width, size.height, x).collect();
get_vertical_clues(&cells, size.clone(), x).collect();
vertical_clues_solutions.push(vertical_clues_solution);
}
let max_clues_height = vertical_clues_solutions
Expand Down Expand Up @@ -115,7 +114,7 @@ impl Grid {
);
}

pub fn get_cell(&self, point: Point) -> Cell {
fn get_cell(&self, point: Point) -> Cell {
let index = get_index(self.size.width, point);
*self
.cells
Expand All @@ -130,12 +129,12 @@ impl Grid {
.unwrap_or_else(|| Self::cell_panic(point, index))
}

pub fn get_horizontal_clues(&self, y: u16) -> impl Iterator<Item = Clue> + '_ {
fn get_horizontal_clues(&self, y: u16) -> impl Iterator<Item = Clue> + '_ {
get_horizontal_clues(&self.cells, self.size.width, y)
}

pub fn get_vertical_clues(&self, x: u16) -> impl Iterator<Item = Clue> + '_ {
get_vertical_clues(&self.cells, self.size.width, self.size.height, x)
fn get_vertical_clues(&self, x: u16) -> impl Iterator<Item = Clue> + '_ {
get_vertical_clues(&self.cells, self.size.clone(), x)
}

pub fn clear(&mut self) {
Expand Down
2 changes: 1 addition & 1 deletion src/grid/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Cell {
}
}

pub fn get_highlighted_color(&self) -> Color {
fn get_highlighted_color(&self) -> Color {
match self {
Cell::Empty => Color::DarkGray,
Cell::Filled => Color::Gray,
Expand Down

0 comments on commit 84a6019

Please sign in to comment.