[−][src]Struct spacebattleship::board::setup::ShipEntryMut
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]
&self,
coord: D::Coordinate
) -> ProjectIter<D, S::ProjectIterState>
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]
&self,
placement: &ShapeProjection<D::Coordinate>
) -> Result<(), CannotPlaceReason>
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]
&mut self,
placement: ShapeProjection<D::Coordinate>
) -> Result<(), PlaceError<ShapeProjection<D::Coordinate>>>
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,
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,
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,
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,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,