[][src]Struct spacebattleship::board::setup::ShipEntryMut

pub struct ShipEntryMut<'a, I, D: Dimensions, S> { /* fields omitted */ }

Reference to a particular ship's placement info as well as the grid, providing access to the methods necessary to check it's placement status and place or unplace it.

Implementations

impl<'a, I: ShipId, D: Dimensions, S: ShipShape<D>> ShipEntryMut<'a, I, D, S>[src]

pub fn id(&self) -> &I[src]

Get the ID of this ship.

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

Returns true if this ship has been placed.

pub fn get_placements(
    &self,
    coord: D::Coordinate
) -> ProjectIter<D, S::ProjectIterState>
[src]

Get an interator over possible projections of the shape for this ship that start from the given [Coordinate]. If there are no possible placements from the given coordinate, including if the coordinate is out of bounds, the resulting iterator will be empty.

pub fn check_placement(
    &self,
    placement: &ShapeProjection<D::Coordinate>
) -> Result<(), CannotPlaceReason>
[src]

Check if the specified placement is valid for this ship.

impl<'a, I: ShipId, D: Dimensions, S: ShipShape<D>> ShipEntryMut<'a, I, D, S>[src]

pub fn placement(&self) -> Option<&ShapeProjection<D::Coordinate>>[src]

If the ship is placed, get the placement. Otherwise return None.

pub fn place(
    &mut self,
    placement: ShapeProjection<D::Coordinate>
) -> Result<(), PlaceError<ShapeProjection<D::Coordinate>>>
[src]

Attempts to place the ship with onto the given coordinates. If the ship is already placed, returns Err with the attempted placement and reason placement failed, otherwise returns Ok(())

pub fn unplace(&mut self) -> Option<ShapeProjection<D::Coordinate>>[src]

Attempt to clear the placement of the ship. Returns the previous placement of the ship if any. Returns None if the ship has not been placed.

Auto Trait Implementations

impl<'a, I, D, S> RefUnwindSafe for ShipEntryMut<'a, I, D, S> where
    D: RefUnwindSafe,
    I: RefUnwindSafe,
    S: RefUnwindSafe,
    <D as Dimensions>::Coordinate: RefUnwindSafe

impl<'a, I, D, S> Send for ShipEntryMut<'a, I, D, S> where
    D: Send,
    I: Send,
    S: Send,
    <D as Dimensions>::Coordinate: Send

impl<'a, I, D, S> Sync for ShipEntryMut<'a, I, D, S> where
    D: Sync,
    I: Sync,
    S: Sync,
    <D as Dimensions>::Coordinate: Sync

impl<'a, I, D, S> Unpin for ShipEntryMut<'a, I, D, S> where
    I: Unpin

impl<'a, I, D, S> !UnwindSafe for ShipEntryMut<'a, I, D, S>

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.