pub struct Board { /* private fields */ }
Expand description
Raw 9x9 board with some useful helpers.
There are multiple ways to create a Board
:
- Using a 2D array of
u8
with dimensions 9x9 - Using a 1D array of
u8
with length 81 - Using a string representation with length 81
Implementations§
Source§impl Board
impl Board
pub fn new(initial_board: [[u8; 9]; 9]) -> Self
Sourcepub fn get(&self, r: usize, c: usize) -> u8
pub fn get(&self, r: usize, c: usize) -> u8
Gets a value from the board at the specified row and column.
Sourcepub fn is_empty(&self, r: usize, c: usize) -> bool
pub fn is_empty(&self, r: usize, c: usize) -> bool
Checks if a cell at the specified row and column is empty (contains 0).
Sourcepub fn iter_cells(&self) -> impl Iterator<Item = (usize, usize)> + '_
pub fn iter_cells(&self) -> impl Iterator<Item = (usize, usize)> + '_
Iterates over all cells in the board, yielding their row and column indices.
Sourcepub fn iter_empty_cells(&self) -> impl Iterator<Item = (usize, usize)> + '_
pub fn iter_empty_cells(&self) -> impl Iterator<Item = (usize, usize)> + '_
Iterates over empty cells in the board, yielding their row and column indices.
Trait Implementations§
impl Copy for Board
impl Eq for Board
impl StructuralPartialEq for Board
Auto Trait Implementations§
impl Freeze for Board
impl RefUnwindSafe for Board
impl Send for Board
impl Sync for Board
impl Unpin for Board
impl UnwindSafe for Board
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more