Struct prototty::Size
[−]
[src]
pub struct Size { /* fields omitted */ }
A size cannot be created which would contain un-addressable cells.
That is, the maximum size has a width and height of one greater than the maximum i32
.
Methods
impl Size
[src]
fn new(x: u32, y: u32) -> Size
[src]
Creates a new Size
.
Panics if x
or y
is greater than ::std::i32::MAX as u32 + 1
.
fn x(&self) -> u32
[src]
Returns the width.
fn y(&self) -> u32
[src]
Returns the height.
fn coords(&self) -> CoordIter
[src]
Returns an iterator over all the coordinates within a rectangle of this size.
fn index(&self, coord: Coord) -> Option<usize>
[src]
Suppose an array is used to implement a 2D grid of this size, where traversing the array from start to end is equivalent to traversing the 2D grid top to bottom, traversing left to right within each row. If a given coordinate is valid for such a grid, this function returns the index into the array corresponding to that coordinate.
fn coord(&self, index: usize) -> Option<Coord>
[src]
fn count(&self) -> usize
[src]
Return the number of cells in a 2D grid of this size.
Trait Implementations
impl Copy for Size
[src]
impl Hash for Size
[src]
fn hash<__H>(&self, __arg_0: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Clone for Size
[src]
fn clone(&self) -> Size
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Eq for Size
[src]
impl<T> From<T> for Size where
T: Into<[u32; 2]>,
[src]
T: Into<[u32; 2]>,
impl PartialEq<Size> for Size
[src]
fn eq(&self, __arg_0: &Size) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Size) -> bool
[src]
This method tests for !=
.
impl<T> Add<T> for Size where
T: Into<Size>,
[src]
T: Into<Size>,
impl Add<Coord> for Size
[src]
impl<'de> Deserialize<'de> for Size
[src]
fn deserialize<__D>(
__deserializer: __D
) -> Result<Size, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
__deserializer: __D
) -> Result<Size, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
impl Debug for Size
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
impl Serialize for Size
[src]
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<T> Sub<T> for Size where
T: Into<Size>,
[src]
T: Into<Size>,