[][src]Struct spacebattleship::board::rectangular::RectDimensions

pub struct RectDimensions { /* fields omitted */ }

Simple rectangular dimensions. Optionally supports wrapping.

Implementations

impl RectDimensions[src]

pub fn new(width: usize, height: usize) -> Self[src]

Create new RectDimensions with the specified width and height. Defaults to no wrapping. Panics if width * height exceeds usize::max_value() or if width or height is 0.

pub fn new_wrapping<B: Into<BitFlags<Wrapping>>>(
    width: usize,
    height: usize,
    wrapping: B
) -> Self
[src]

Create new RectDimensions with the specified width and height, wrapping on the specified axes. Panics if width * height exceeds usize::max_value() or if width or height is 0.

pub fn try_new(width: usize, height: usize) -> Option<Self>[src]

Create new RectDimensions with the specified width and height. Defaults to no wrapping. Returns None if width * height exceeds usize::max_value() or if width or height is 0.

pub fn try_new_wrapping<B: Into<BitFlags<Wrapping>>>(
    width: usize,
    height: usize,
    wrapping: B
) -> Option<Self>
[src]

Create new RectDimensions with the specified width and height. Returns None if width * height exceeds usize::max_value() or if width or height is 0.

pub fn width(&self) -> usize[src]

Get the width of these RectDimensions.

pub fn height(&self) -> usize[src]

Get the height of these RectDimensions.

pub fn wrapping(&self) -> BitFlags<Wrapping>[src]

Get the wrapping modes of these RectDimensions.

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

Whether the grid wraps along the x direciton.

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

Whether the grid wraps along the y direciton.

pub fn iter_coordinates(
    &self
) -> impl Iterator<Item = impl Iterator<Item = Coordinate>>
[src]

Get an iterator over rows of this grid. Each row is an iterator over the coordinates of that row.

Trait Implementations

impl Clone for RectDimensions[src]

impl ColinearCheck for RectDimensions[src]

impl Copy for RectDimensions[src]

impl Debug for RectDimensions[src]

impl Default for RectDimensions[src]

fn default() -> Self[src]

Construct the default rectangular dimensions, a 10x10 board with no wrapping.

impl Dimensions for RectDimensions[src]

type Coordinate = Coordinate

The type used to identify cells on the board.

type NeighborIterState = RectNeighbors

Type used in the neighbor iterator.

fn total_size(&self) -> usize[src]

Compute the linear total size of these Dimensions.

fn try_linearize(&self, coord: &Self::Coordinate) -> Option<usize>[src]

Convert a coordinate to a linear index within this dimension. Returns None if the coordinate is out of range for the dimension.

impl Eq for RectDimensions[src]

impl PartialEq<RectDimensions> for RectDimensions[src]

impl StructuralEq for RectDimensions[src]

impl StructuralPartialEq for RectDimensions[src]

Auto Trait Implementations

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.