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
pub const fn try_new(
width: u32,
height: u32
) -> Result<Self, DimensionTooLargeForSize>
sourcepub fn new(width: u32, height: u32) -> Self
pub fn new(width: u32, height: u32) -> Self
Creates a new Size
.
Panics if width
or width
is greater than ::core::i32::MAX as u32 + 1
.
sourcepub const fn new_u16(width: u16, height: u16) -> Self
pub const fn new_u16(width: u16, height: u16) -> Self
Like new, but const and never panics as it’s impossible to construct an invalid size
pub fn from_coord(coord: Coord) -> Result<Self, NegativeDimension>
pub const fn to_coord(self) -> Result<Coord, DimensionTooLargeForCoord>
pub const fn get(self, axis: Axis) -> u32
pub fn get_mut(&mut self, axis: Axis) -> &mut u32
pub fn with_axis<F: FnMut(u32) -> u32>(self, axis: Axis, f: F) -> Self
pub const fn try_set(
self,
axis: Axis,
value: u32
) -> Result<Self, DimensionTooLargeForSize>
pub fn set(self, axis: Axis, value: u32) -> Self
pub fn try_set_in_place(
&mut self,
axis: Axis,
value: u32
) -> Result<(), DimensionTooLargeForSize>
pub fn set_in_place(&mut self, axis: Axis, value: u32)
pub const fn try_new_axis(
this_axis: u32,
other_axis: u32,
axis: Axis
) -> Result<Self, DimensionTooLargeForSize>
pub fn new_axis(this_axis: u32, other_axis: u32, axis: Axis) -> Self
pub fn get_static<A: StaticAxis>(self) -> u32
pub fn get_static_mut<A: StaticAxis>(&mut self) -> &mut u32
pub fn with_static_axis<A: StaticAxis, F: FnMut(u32) -> u32>(self, f: F) -> Self
pub fn try_set_static<A: StaticAxis>(
self,
value: u32
) -> Result<Self, DimensionTooLargeForSize>
pub fn try_set_static_in_place<A: StaticAxis>(
&mut self,
value: u32
) -> Result<(), DimensionTooLargeForSize>
pub fn set_static<A: StaticAxis>(self, value: u32) -> Self
pub fn set_static_in_place<A: StaticAxis>(&mut self, value: u32)
pub fn try_new_static_axis<A: StaticAxis>(
this_axis: u32,
other_axis: u32
) -> Result<Self, DimensionTooLargeForSize>
pub fn new_static_axis<A: StaticAxis>(this_axis: u32, other_axis: u32) -> Self
pub fn try_set_width(self, width: u32) -> Result<Self, DimensionTooLargeForSize>
pub fn try_set_height(
self,
height: u32
) -> Result<Self, DimensionTooLargeForSize>
pub fn set_width(self, width: u32) -> Self
pub fn set_height(self, height: u32) -> Self
pub fn try_set_width_in_place(
&mut self,
width: u32
) -> Result<(), DimensionTooLargeForSize>
pub fn try_set_height_in_place(
&mut self,
height: u32
) -> Result<(), DimensionTooLargeForSize>
pub fn set_width_in_place(&mut self, width: u32)
pub fn set_height_in_place(&mut self, height: u32)
pub fn checked_sub(self, rhs: Self) -> Option<Self>
pub fn saturating_sub(self, rhs: Self) -> Self
pub const fn max_field() -> u32
pub const fn max() -> Self
pub const fn is_zero(self) -> bool
pub const fn is_valid(self, coord: Coord) -> bool
pub const fn constrain(self, coord: Coord) -> Option<Coord>
pub const fn coord_iter_row_major(self) -> CoordIterRowMajorⓘNotable traits for CoordIterRowMajorimpl Iterator for CoordIterRowMajor type Item = Coord;
pub fn pairwise_max(self, other: Self) -> Self
pub fn pairwise_min(self, other: Self) -> Self
pub const fn transpose(self) -> Self
pub const fn is_empty(self) -> bool
pub const fn is_on_edge(self, _: Coord) -> bool
pub fn edge_iter(self) -> EdgeIterⓘNotable traits for Iterimpl Iterator for Iter type Item = 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 moresourceimpl Ord for Size
impl Ord for Size
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Size> for Size
impl PartialOrd<Size> for Size
sourcefn partial_cmp(&self, other: &Size) -> Option<Ordering>
fn partial_cmp(&self, other: &Size) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. 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