[][src]Struct spacebattleship::board::Board

pub struct Board<I: ShipId, D: Dimensions> { /* fields omitted */ }

Represents a single player's board, including their ships and their side of the ocean.

Implementations

impl<I: ShipId, D: Dimensions> Board<I, D>[src]

pub fn dimensions(&self) -> &D[src]

Get the [Dimesnsions] of this Board.

pub fn defeated(&self) -> bool[src]

Returns true if all of this player's ships have been sunk.

pub fn iter_ships(&self) -> impl Iterator<Item = ShipRef<I, D>>[src]

Get an iterator over all ships on this board.

pub fn get_ship<Q: ?Sized>(&self, ship: &Q) -> Option<ShipRef<I, D>> where
    I: Borrow<Q>,
    Q: Hash + Eq
[src]

Get the ship with the specified ID if it exists.

pub fn get_coord(&self, coord: D::Coordinate) -> Option<CellRef<I, D>>[src]

Get a reference to the cell at the given coordinate. Returns None if the coordinate is out of bounds.

pub fn shoot(
    &mut self,
    coord: D::Coordinate
) -> Result<ShotOutcome<I>, ShotError<D::Coordinate>>
[src]

Fire a shot at this player, returning a result indicating why the shot was aborted or the result of the shot on this player.

Auto Trait Implementations

impl<I, D> RefUnwindSafe for Board<I, D> where
    D: RefUnwindSafe,
    I: RefUnwindSafe,
    <D as Dimensions>::Coordinate: RefUnwindSafe

impl<I, D> Send for Board<I, D> where
    D: Send,
    I: Send,
    <D as Dimensions>::Coordinate: Send

impl<I, D> Sync for Board<I, D> where
    D: Sync,
    I: Sync,
    <D as Dimensions>::Coordinate: Sync

impl<I, D> Unpin for Board<I, D> where
    D: Unpin,
    I: Unpin,
    <D as Dimensions>::Coordinate: Unpin

impl<I, D> UnwindSafe for Board<I, D> where
    D: UnwindSafe,
    I: UnwindSafe,
    <D as Dimensions>::Coordinate: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.