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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Construct a Board from a 2D array.

Create a Board with the given content.

The cells parameter is a two dimensional array slice.

Example
let board = Board::from(&[[0u8; BOARD_SIZE]; BOARD_SIZE]);

From implementation for SolutionIter.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.