Struct Size

Source
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§

Source§

impl Size

Source

pub fn try_new( width: u32, height: u32, ) -> Result<Size, DimensionTooLargeForSize>

Source

pub fn new(width: u32, height: u32) -> Size

Creates a new Size. Panics if width or width is greater than ::core::i32::MAX as u32 + 1.

Source

pub const fn new_u16(width: u16, height: u16) -> Size

Like new, but const and never panics as it’s impossible to construct an invalid size

Source

pub fn from_coord(coord: Coord) -> Result<Size, NegativeDimension>

Source

pub fn to_coord(self) -> Result<Coord, DimensionTooLargeForCoord>

Source

pub fn get(self, axis: Axis) -> u32

Source

pub fn get_mut(&mut self, axis: Axis) -> &mut u32

Source

pub fn with_axis<F>(self, axis: Axis, f: F) -> Size
where F: FnMut(u32) -> u32,

Source

pub fn try_set( self, axis: Axis, value: u32, ) -> Result<Size, DimensionTooLargeForSize>

Source

pub fn set(self, axis: Axis, value: u32) -> Size

Source

pub fn try_set_in_place( &mut self, axis: Axis, value: u32, ) -> Result<(), DimensionTooLargeForSize>

Source

pub fn set_in_place(&mut self, axis: Axis, value: u32)

Source

pub fn try_new_axis( this_axis: u32, other_axis: u32, axis: Axis, ) -> Result<Size, DimensionTooLargeForSize>

Source

pub fn new_axis(this_axis: u32, other_axis: u32, axis: Axis) -> Size

Source

pub fn get_static<A>(self) -> u32
where A: StaticAxis,

Source

pub fn get_static_mut<A>(&mut self) -> &mut u32
where A: StaticAxis,

Source

pub fn with_static_axis<A, F>(self, f: F) -> Size
where A: StaticAxis, F: FnMut(u32) -> u32,

Source

pub fn try_set_static<A>( self, value: u32, ) -> Result<Size, DimensionTooLargeForSize>
where A: StaticAxis,

Source

pub fn try_set_static_in_place<A>( &mut self, value: u32, ) -> Result<(), DimensionTooLargeForSize>
where A: StaticAxis,

Source

pub fn set_static<A>(self, value: u32) -> Size
where A: StaticAxis,

Source

pub fn set_static_in_place<A>(&mut self, value: u32)
where A: StaticAxis,

Source

pub fn try_new_static_axis<A>( this_axis: u32, other_axis: u32, ) -> Result<Size, DimensionTooLargeForSize>
where A: StaticAxis,

Source

pub fn new_static_axis<A>(this_axis: u32, other_axis: u32) -> Size
where A: StaticAxis,

Source

pub fn try_set_width(self, width: u32) -> Result<Size, DimensionTooLargeForSize>

Source

pub fn try_set_height( self, height: u32, ) -> Result<Size, DimensionTooLargeForSize>

Source

pub fn set_width(self, width: u32) -> Size

Source

pub fn set_height(self, height: u32) -> Size

Source

pub fn try_set_width_in_place( &mut self, width: u32, ) -> Result<(), DimensionTooLargeForSize>

Source

pub fn try_set_height_in_place( &mut self, height: u32, ) -> Result<(), DimensionTooLargeForSize>

Source

pub fn set_width_in_place(&mut self, width: u32)

Source

pub fn set_height_in_place(&mut self, height: u32)

Source

pub const fn width(self) -> u32

Returns the width.

Source

pub const fn x(self) -> u32

Alias for width.

Source

pub const fn height(self) -> u32

Returns the height.

Source

pub const fn y(self) -> u32

Alias for height.

Source

pub const fn count(self) -> usize

Return the number of cells in a 2D grid of this size.

Source

pub fn checked_sub(self, rhs: Size) -> Option<Size>

Source

pub fn saturating_sub(self, rhs: Size) -> Size

Source

pub const fn max_field() -> u32

Source

pub const fn max() -> Size

Source

pub fn is_zero(self) -> bool

Source

pub fn is_valid(self, coord: Coord) -> bool

Source

pub fn constrain(self, coord: Coord) -> Option<Coord>

Source

pub fn coord_iter_row_major(self) -> CoordIterRowMajor

Source

pub fn pairwise_max(self, other: Size) -> Size

Source

pub fn pairwise_min(self, other: Size) -> Size

Trait Implementations§

Source§

impl<'a, 'b> Add<&'a Coord> for &'b Size

Source§

type Output = Coord

The resulting type after applying the + operator.
Source§

fn add(self, _: &'a Coord) -> <&'b Size as Add<&'a Coord>>::Output

Performs the + operation. Read more
Source§

impl<'a> Add<&'a Coord> for Size

Source§

type Output = Coord

The resulting type after applying the + operator.
Source§

fn add(self, _: &'a Coord) -> <Size as Add<&'a Coord>>::Output

Performs the + operation. Read more
Source§

impl<'a, 'b> Add<&'a Size> for &'b Coord

Source§

type Output = Coord

The resulting type after applying the + operator.
Source§

fn add(self, size: &'a Size) -> <&'b Coord as Add<&'a Size>>::Output

Performs the + operation. Read more
Source§

impl<'a, 'b> Add<&'a Size> for &'b Size

Source§

type Output = Size

The resulting type after applying the + operator.
Source§

fn add(self, size: &'a Size) -> <&'b Size as Add<&'a Size>>::Output

Performs the + operation. Read more
Source§

impl<'a> Add<&'a Size> for Coord

Source§

type Output = Coord

The resulting type after applying the + operator.
Source§

fn add(self, size: &'a Size) -> <Coord as Add<&'a Size>>::Output

Performs the + operation. Read more
Source§

impl<'a> Add<&'a Size> for Size

Source§

type Output = Size

The resulting type after applying the + operator.
Source§

fn add(self, size: &'a Size) -> <Size as Add<&'a Size>>::Output

Performs the + operation. Read more
Source§

impl<'a> Add<Coord> for &'a Size

Source§

type Output = Coord

The resulting type after applying the + operator.
Source§

fn add(self, _: Coord) -> <&'a Size as Add<Coord>>::Output

Performs the + operation. Read more
Source§

impl Add<Coord> for Size

Source§

type Output = Coord

The resulting type after applying the + operator.
Source§

fn add(self, _: Coord) -> <Size as Add<Coord>>::Output

Performs the + operation. Read more
Source§

impl<'a> Add<Size> for &'a Coord

Source§

type Output = Coord

The resulting type after applying the + operator.
Source§

fn add(self, size: Size) -> <&'a Coord as Add<Size>>::Output

Performs the + operation. Read more
Source§

impl<'a> Add<Size> for &'a Size

Source§

type Output = Size

The resulting type after applying the + operator.
Source§

fn add(self, size: Size) -> <&'a Size as Add<Size>>::Output

Performs the + operation. Read more
Source§

impl Add<Size> for Coord

Source§

type Output = Coord

The resulting type after applying the + operator.
Source§

fn add(self, size: Size) -> <Coord as Add<Size>>::Output

Performs the + operation. Read more
Source§

impl Add for Size

Source§

type Output = Size

The resulting type after applying the + operator.
Source§

fn add(self, size: Size) -> <Size as Add>::Output

Performs the + operation. Read more
Source§

impl Clone for Size

Source§

fn clone(&self) -> Size

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Size

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Size

Source§

fn default() -> Size

Returns the “default value” for a type. Read more
Source§

impl<'a> Div<u32> for &'a Size

Source§

type Output = Size

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u32) -> <&'a Size as Div<u32>>::Output

Performs the / operation. Read more
Source§

impl Div<u32> for Size

Source§

type Output = Size

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u32) -> <Size as Div<u32>>::Output

Performs the / operation. Read more
Source§

impl<T> DivAssign<T> for Size
where Size: Div<T, Output = Size>,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl From<[u32; 2]> for Size

Source§

fn from(array: [u32; 2]) -> Size

Converts to this type from the input type.
Source§

impl From<(u32, u32)> for Size

Source§

fn from(_: (u32, u32)) -> Size

Converts to this type from the input type.
Source§

impl Hash for Size

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> Mul<u32> for &'a Size

Source§

type Output = Size

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u32) -> <&'a Size as Mul<u32>>::Output

Performs the * operation. Read more
Source§

impl Mul<u32> for Size

Source§

type Output = Size

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u32) -> <Size as Mul<u32>>::Output

Performs the * operation. Read more
Source§

impl<T> MulAssign<T> for Size
where Size: Mul<T, Output = Size>,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl Ord for Size

Source§

fn cmp(&self, other: &Size) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Size

Source§

fn eq(&self, other: &Size) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Size

Source§

fn partial_cmp(&self, other: &Size) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b> Sub<&'a Coord> for &'b Size

Source§

type Output = Coord

The resulting type after applying the - operator.
Source§

fn sub(self, _: &'a Coord) -> <&'b Size as Sub<&'a Coord>>::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<&'a Coord> for Size

Source§

type Output = Coord

The resulting type after applying the - operator.
Source§

fn sub(self, _: &'a Coord) -> <Size as Sub<&'a Coord>>::Output

Performs the - operation. Read more
Source§

impl<'a, 'b> Sub<&'a Size> for &'b Coord

Source§

type Output = Coord

The resulting type after applying the - operator.
Source§

fn sub(self, size: &'a Size) -> <&'b Coord as Sub<&'a Size>>::Output

Performs the - operation. Read more
Source§

impl<'a, 'b> Sub<&'a Size> for &'b Size

Source§

type Output = Size

The resulting type after applying the - operator.
Source§

fn sub(self, size: &'a Size) -> <&'b Size as Sub<&'a Size>>::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<&'a Size> for Coord

Source§

type Output = Coord

The resulting type after applying the - operator.
Source§

fn sub(self, size: &'a Size) -> <Coord as Sub<&'a Size>>::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<&'a Size> for Size

Source§

type Output = Size

The resulting type after applying the - operator.
Source§

fn sub(self, size: &'a Size) -> <Size as Sub<&'a Size>>::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<Coord> for &'a Size

Source§

type Output = Coord

The resulting type after applying the - operator.
Source§

fn sub(self, _: Coord) -> <&'a Size as Sub<Coord>>::Output

Performs the - operation. Read more
Source§

impl Sub<Coord> for Size

Source§

type Output = Coord

The resulting type after applying the - operator.
Source§

fn sub(self, _: Coord) -> <Size as Sub<Coord>>::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<Size> for &'a Coord

Source§

type Output = Coord

The resulting type after applying the - operator.
Source§

fn sub(self, size: Size) -> <&'a Coord as Sub<Size>>::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<Size> for &'a Size

Source§

type Output = Size

The resulting type after applying the - operator.
Source§

fn sub(self, size: Size) -> <&'a Size as Sub<Size>>::Output

Performs the - operation. Read more
Source§

impl Sub<Size> for Coord

Source§

type Output = Coord

The resulting type after applying the - operator.
Source§

fn sub(self, size: Size) -> <Coord as Sub<Size>>::Output

Performs the - operation. Read more
Source§

impl Sub for Size

Source§

type Output = Size

The resulting type after applying the - operator.
Source§

fn sub(self, size: Size) -> <Size as Sub>::Output

Performs the - operation. Read more
Source§

impl Copy for Size

Source§

impl Eq for Size

Source§

impl StructuralPartialEq for Size

Auto Trait Implementations§

§

impl Freeze for Size

§

impl RefUnwindSafe for Size

§

impl Send for Size

§

impl Sync for Size

§

impl Unpin for Size

§

impl UnwindSafe for Size

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.