Struct sudoku_solver::board::Board [−][src]
pub struct Board { /* fields omitted */ }
Expand description
A representation of a puzzle or solution.
Implementations
Get the contents of the cell at the given coordinates.
This returns the contents of the cell at column x
and row y
. A zero represents a cell
which is unfilled, otherwise the value will be between 1 and 9 inclusive.
Example
let board = Board::from(&[
[0, 2, 0, 0, 0, 0, 0, 0, 0], // row 1
[0, 0, 0, 6, 0, 0, 0, 0, 3], // row 2
[0, 7, 4, 0, 8, 0, 0, 0, 0], // row 3
[0, 0, 0, 0, 0, 3, 0, 0, 2], // row 4
[0, 8, 0, 0, 4, 0, 0, 1, 0], // row 5
[6, 0, 0, 5, 0, 0, 0, 0, 0], // row 6
[0, 0, 0, 0, 1, 0, 7, 8, 0], // row 7
[5, 0, 0, 0, 0, 9, 0, 0, 0], // row 8
[0, 0, 0, 0, 0, 0, 0, 4, 0], // row 9
]);
assert_eq!(board.get_cell(1, 0), 2);
Set the contents of the cell at the given coordinates to the given value.
Example
let mut board = Board::from(&[[0u8; BOARD_SIZE]; BOARD_SIZE]);
board.set_cell(1, 1, 9);
assert_eq!(board.get_cell(1, 1), 9);
Construct a board which is obtained from the input board by modifying a single cell.
The returned board is the same as the input one, except that the cell at column x
and row
y
will contain value
.
Example
let board = Board::from(&[[0u8; BOARD_SIZE]; BOARD_SIZE]);
let board = board.with_cell(1, 1, 9);
assert_eq!(board.get_cell(1, 1), 9);
Trait Implementations
Construct a Board
from a 2D array.
From
implementation for SolutionIter
.
Auto Trait Implementations
impl RefUnwindSafe for Board
impl UnwindSafe for Board
Blanket Implementations
Mutably borrows from an owned value. Read more