[−][src]Struct spacebattleship::board::rectangular::RectDimensions
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]
width: usize,
height: usize,
wrapping: B
) -> Self
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]
width: usize,
height: usize,
wrapping: B
) -> Option<Self>
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]
&self
) -> impl Iterator<Item = impl Iterator<Item = Coordinate>>
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]
fn clone(&self) -> RectDimensions
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl ColinearCheck for RectDimensions
[src]
fn is_colinear(&self, c1: &Coordinate, c2: &Coordinate, c3: &Coordinate) -> bool
[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.
fn linearize(&self, coord: &Self::Coordinate) -> usize
[src]
fn neighbors(
&self,
coord: Self::Coordinate
) -> NeighborIter<Self::NeighborIterState>
[src]
&self,
coord: Self::Coordinate
) -> NeighborIter<Self::NeighborIterState>
fn is_neighbor(&self, c1: &Self::Coordinate, c2: &Self::Coordinate) -> bool
[src]
impl Eq for RectDimensions
[src]
impl PartialEq<RectDimensions> for RectDimensions
[src]
fn eq(&self, other: &RectDimensions) -> bool
[src]
fn ne(&self, other: &RectDimensions) -> bool
[src]
impl StructuralEq for RectDimensions
[src]
impl StructuralPartialEq for RectDimensions
[src]
Auto Trait Implementations
impl RefUnwindSafe for RectDimensions
impl Send for RectDimensions
impl Sync for RectDimensions
impl Unpin for RectDimensions
impl UnwindSafe for RectDimensions
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,