[][src]Trait spacebattleship::ships::ShipShape

pub trait ShipShape<D: Dimensions + ?Sized> {
    type ProjectIterState: ProjectIterState<D, ShipShape = Self>;
    fn is_valid_placement(
        &self,
        proj: &ShapeProjection<D::Coordinate>,
        dim: &D
    ) -> bool; fn project<'a>(
        &'a self,
        coord: D::Coordinate,
        dim: &'a D
    ) -> ProjectIter<D, Self::ProjectIterState> { ... } }

Trait for shapes that a ship can be.

Associated Types

type ProjectIterState: ProjectIterState<D, ShipShape = Self>

Loading content...

Required methods

fn is_valid_placement(
    &self,
    proj: &ShapeProjection<D::Coordinate>,
    dim: &D
) -> bool

Return true if the given shape projection is a valid placement of this ship in the specified dimensions. Does not account for whether cells are already occupied. Shapes are free to reject any placement that they did not generate.

Loading content...

Provided methods

fn project<'a>(
    &'a self,
    coord: D::Coordinate,
    dim: &'a D
) -> ProjectIter<D, Self::ProjectIterState>

Get an iterator over possible placements of this ship shap in the given dimensions. Does not in any way account for whether cells are already occupied or not.

Loading content...

Implementors

impl<D: Dimensions + ColinearCheck + ?Sized> ShipShape<D> for Line[src]

type ProjectIterState = LineProjectIterState<D::Coordinate>

Loading content...