pub struct Size { /* private fields */ }
Expand description
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
.
Implementations
sourceimpl Size
impl Size
sourcepub fn new(x: u32, y: u32) -> Self
pub fn new(x: u32, y: u32) -> Self
Creates a new Size
.
Panics if x
or y
is greater than ::std::i32::MAX as u32 + 1
.
sourcepub fn coords(&self) -> CoordIterⓘNotable traits for CoordIterimpl Iterator for CoordIter type Item = Coord;
pub fn coords(&self) -> CoordIterⓘNotable traits for CoordIterimpl Iterator for CoordIter type Item = Coord;
Returns an iterator over all the coordinates within a rectangle of this size.
sourcepub fn index(&self, coord: Coord) -> Option<usize>
pub fn index(&self, coord: Coord) -> Option<usize>
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.
pub fn coord(&self, index: usize) -> Option<Coord>
Trait Implementations
sourceimpl<T> DivAssign<T> for Sizewhere
Size: Div<T, Output = Size>,
impl<T> DivAssign<T> for Sizewhere
Size: Div<T, Output = Size>,
sourcefn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/=
operation. Read moresourceimpl<T> MulAssign<T> for Sizewhere
Size: Mul<T, Output = Size>,
impl<T> MulAssign<T> for Sizewhere
Size: Mul<T, Output = Size>,
sourcefn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*=
operation. Read moreimpl Copy for Size
impl Eq for Size
impl StructuralEq for Size
impl StructuralPartialEq for Size
Auto Trait Implementations
impl RefUnwindSafe for Size
impl Send for Size
impl Sync for Size
impl Unpin for Size
impl UnwindSafe for Size
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more