pub struct Board { /* private fields */ }Expand description
Sparse board storage: maps placed coordinates to their owning player.
Implementations§
Source§impl Board
impl Board
Sourcepub fn place(&mut self, coord: Coord, player: Player) -> Result<(), PlaceError>
pub fn place(&mut self, coord: Coord, player: Player) -> Result<(), PlaceError>
Places player’s stone at coord.
Returns Err(PlaceError::CellOccupied) if the cell already has a stone.
Sourcepub fn get(&self, coord: Coord) -> Option<Player>
pub fn get(&self, coord: Coord) -> Option<Player>
Returns the player whose stone occupies coord, or None if empty.
Sourcepub fn stones(&self) -> &HashMap<Coord, Player>
pub fn stones(&self) -> &HashMap<Coord, Player>
Returns a reference to the underlying stone map.
Sourcepub fn stone_count(&self) -> usize
pub fn stone_count(&self) -> usize
Returns the total number of stones on the board.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Board
impl RefUnwindSafe for Board
impl Send for Board
impl Sync for Board
impl Unpin for Board
impl UnsafeUnpin 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