pub struct Board { /* private fields */ }
Expand description
Default implementation of the SweeperBoard trait
Implementations§
Trait Implementations§
Source§impl SweeperBoard<Cell> for Board
impl SweeperBoard<Cell> for Board
Source§fn new(height: usize, width: usize, mine_count: usize) -> Result<Self, Error>
fn new(height: usize, width: usize, mine_count: usize) -> Result<Self, Error>
Create a new minesweeper board. height
and width
cannot be under 9,
while mine_count
cannot exceed height * width - 9
since the initial
cell and its neighbors must be a free cell. Return error if given invalid
configuration.
Source§fn open(&mut self, i: usize, j: usize) -> &CellKind
fn open(&mut self, i: usize, j: usize) -> &CellKind
Open a cell, propagate if all neighboring cell is a free cell. Opening an opened cell will propagate if flagged cell count is equal to surrounding mine count.
Propagation is stopped when propagation reached a mine cell.
Source§fn flag(&mut self, i: usize, j: usize) -> &CellState
fn flag(&mut self, i: usize, j: usize) -> &CellState
Flag a cell. Flagged cell cannot be opened until unflagged. Remove the flag by flagging a flagged cell again. Flagged cell counts toward opening an opened cell propagation.
fn open_save(&mut self, i: usize, j: usize) -> Result<&CellKind, Error>
fn flag_save(&mut self, i: usize, j: usize) -> Result<&CellState, Error>
fn state(&self) -> &BoardState
fn cells(&self) -> &Vec<Vec<Cell>>
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