[−]Struct chargrid_web::Size
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
pub fn try_new(
width: u32,
height: u32
) -> Result<Size, DimensionTooLargeForSize>
width: u32,
height: u32
) -> Result<Size, DimensionTooLargeForSize>
pub fn new(width: u32, height: u32) -> Size
Creates a new Size
.
Panics if width
or width
is greater than ::std::i32::MAX as u32 + 1
.
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
pub fn from_coord(coord: Coord) -> Result<Size, NegativeDimension>
pub fn to_coord(self) -> Result<Coord, DimensionTooLargeForCoord>
pub fn get(self, axis: Axis) -> u32
pub fn get_mut(&mut self, axis: Axis) -> &mut u32
pub fn with_axis<F>(self, axis: Axis, f: F) -> Size where
F: FnMut(u32) -> u32,
F: FnMut(u32) -> u32,
pub fn try_set(
self,
axis: Axis,
value: u32
) -> Result<Size, DimensionTooLargeForSize>
self,
axis: Axis,
value: u32
) -> Result<Size, DimensionTooLargeForSize>
pub fn set(self, axis: Axis, value: u32) -> Size
pub fn try_set_in_place(
&mut self,
axis: Axis,
value: u32
) -> Result<(), DimensionTooLargeForSize>
&mut self,
axis: Axis,
value: u32
) -> Result<(), DimensionTooLargeForSize>
pub fn set_in_place(&mut self, axis: Axis, value: u32)
pub fn try_new_axis(
this_axis: u32,
other_axis: u32,
axis: Axis
) -> Result<Size, DimensionTooLargeForSize>
this_axis: u32,
other_axis: u32,
axis: Axis
) -> Result<Size, DimensionTooLargeForSize>
pub fn new_axis(this_axis: u32, other_axis: u32, axis: Axis) -> Size
pub fn get_static<A>(self) -> u32 where
A: StaticAxis,
A: StaticAxis,
pub fn get_static_mut<A>(&mut self) -> &mut u32 where
A: StaticAxis,
A: StaticAxis,
pub fn with_static_axis<A, F>(self, f: F) -> Size where
A: StaticAxis,
F: FnMut(u32) -> u32,
A: StaticAxis,
F: FnMut(u32) -> u32,
pub fn try_set_static<A>(
self,
value: u32
) -> Result<Size, DimensionTooLargeForSize> where
A: StaticAxis,
self,
value: u32
) -> Result<Size, DimensionTooLargeForSize> where
A: StaticAxis,
pub fn try_set_static_in_place<A>(
&mut self,
value: u32
) -> Result<(), DimensionTooLargeForSize> where
A: StaticAxis,
&mut self,
value: u32
) -> Result<(), DimensionTooLargeForSize> where
A: StaticAxis,
#[must_use]pub fn set_static<A>(self, value: u32) -> Size where
A: StaticAxis,
A: StaticAxis,
pub fn set_static_in_place<A>(&mut self, value: u32) where
A: StaticAxis,
A: StaticAxis,
pub fn try_new_static_axis<A>(
this_axis: u32,
other_axis: u32
) -> Result<Size, DimensionTooLargeForSize> where
A: StaticAxis,
this_axis: u32,
other_axis: u32
) -> Result<Size, DimensionTooLargeForSize> where
A: StaticAxis,
pub fn new_static_axis<A>(this_axis: u32, other_axis: u32) -> Size where
A: StaticAxis,
A: StaticAxis,
pub fn try_set_width(self, width: u32) -> Result<Size, DimensionTooLargeForSize>
pub fn try_set_height(
self,
height: u32
) -> Result<Size, DimensionTooLargeForSize>
self,
height: u32
) -> Result<Size, DimensionTooLargeForSize>
#[must_use]pub fn set_width(self, width: u32) -> Size
#[must_use]pub fn set_height(self, height: u32) -> Size
pub fn try_set_width_in_place(
&mut self,
width: u32
) -> Result<(), DimensionTooLargeForSize>
&mut self,
width: u32
) -> Result<(), DimensionTooLargeForSize>
pub fn try_set_height_in_place(
&mut self,
height: u32
) -> Result<(), DimensionTooLargeForSize>
&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 const fn width(self) -> u32
Returns the width.
pub const fn x(self) -> u32
Alias for width
.
pub const fn height(self) -> u32
Returns the height.
pub const fn y(self) -> u32
Alias for height
.
pub const fn count(self) -> usize
Return the number of cells in a 2D grid of this size.
pub fn checked_sub(self, rhs: Size) -> Option<Size>
pub fn saturating_sub(self, rhs: Size) -> Size
pub const fn max_field() -> u32
pub const fn max() -> Size
pub fn is_zero(self) -> bool
pub fn is_valid(self, coord: Coord) -> bool
pub fn constrain(self, coord: Coord) -> Option<Coord>
Trait Implementations
impl<'a> Add<&'a Coord> for Size
type Output = Coord
The resulting type after applying the +
operator.
fn add(self, &'a Coord) -> <Size as Add<&'a Coord>>::Output
impl<'a, 'b> Add<&'a Coord> for &'b Size
type Output = Coord
The resulting type after applying the +
operator.
fn add(self, &'a Coord) -> <&'b Size as Add<&'a Coord>>::Output
impl<'a, 'b> Add<&'a Size> for &'b Size
type Output = Size
The resulting type after applying the +
operator.
fn add(self, size: &'a Size) -> <&'b Size as Add<&'a Size>>::Output
impl<'a> Add<&'a Size> for Size
type Output = Size
The resulting type after applying the +
operator.
fn add(self, size: &'a Size) -> <Size as Add<&'a Size>>::Output
impl<'a> Add<Coord> for &'a Size
type Output = Coord
The resulting type after applying the +
operator.
fn add(self, Coord) -> <&'a Size as Add<Coord>>::Output
impl Add<Coord> for Size
type Output = Coord
The resulting type after applying the +
operator.
fn add(self, Coord) -> <Size as Add<Coord>>::Output
impl<'a> Add<Size> for &'a Size
type Output = Size
The resulting type after applying the +
operator.
fn add(self, size: Size) -> <&'a Size as Add<Size>>::Output
impl Add<Size> for Size
type Output = Size
The resulting type after applying the +
operator.
fn add(self, size: Size) -> <Size as Add<Size>>::Output
impl Clone for Size
fn clone(&self) -> Size
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Size
impl Debug for Size
impl Default for Size
impl<'a> Div<u32> for &'a Size
type Output = Size
The resulting type after applying the /
operator.
fn div(self, rhs: u32) -> <&'a Size as Div<u32>>::Output
impl Div<u32> for Size
type Output = Size
The resulting type after applying the /
operator.
fn div(self, rhs: u32) -> <Size as Div<u32>>::Output
impl<T> DivAssign<T> for Size where
Size: Div<T>,
<Size as Div<T>>::Output == Size,
Size: Div<T>,
<Size as Div<T>>::Output == Size,
fn div_assign(&mut self, rhs: T)
impl Eq for Size
impl From<[u32; 2]> for Size
impl From<(u32, u32)> for Size
impl Hash for Size
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Mul<u32> for Size
type Output = Size
The resulting type after applying the *
operator.
fn mul(self, rhs: u32) -> <Size as Mul<u32>>::Output
impl<'a> Mul<u32> for &'a Size
type Output = Size
The resulting type after applying the *
operator.
fn mul(self, rhs: u32) -> <&'a Size as Mul<u32>>::Output
impl<T> MulAssign<T> for Size where
Size: Mul<T>,
<Size as Mul<T>>::Output == Size,
Size: Mul<T>,
<Size as Mul<T>>::Output == Size,
fn mul_assign(&mut self, rhs: T)
impl Ord for Size
fn cmp(&self, other: &Size) -> Ordering
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Size> for Size
impl PartialOrd<Size> for Size
fn partial_cmp(&self, other: &Size) -> Option<Ordering>
fn lt(&self, other: &Size) -> bool
fn le(&self, other: &Size) -> bool
fn gt(&self, other: &Size) -> bool
fn ge(&self, other: &Size) -> bool
impl StructuralEq for Size
impl StructuralPartialEq for Size
impl<'a> Sub<&'a Coord> for Size
type Output = Coord
The resulting type after applying the -
operator.
fn sub(self, &'a Coord) -> <Size as Sub<&'a Coord>>::Output
impl<'a, 'b> Sub<&'a Coord> for &'b Size
type Output = Coord
The resulting type after applying the -
operator.
fn sub(self, &'a Coord) -> <&'b Size as Sub<&'a Coord>>::Output
impl<'a, 'b> Sub<&'a Size> for &'b Size
type Output = Size
The resulting type after applying the -
operator.
fn sub(self, size: &'a Size) -> <&'b Size as Sub<&'a Size>>::Output
impl<'a> Sub<&'a Size> for Size
type Output = Size
The resulting type after applying the -
operator.
fn sub(self, size: &'a Size) -> <Size as Sub<&'a Size>>::Output
impl<'a> Sub<Coord> for &'a Size
type Output = Coord
The resulting type after applying the -
operator.
fn sub(self, Coord) -> <&'a Size as Sub<Coord>>::Output
impl Sub<Coord> for Size
type Output = Coord
The resulting type after applying the -
operator.
fn sub(self, Coord) -> <Size as Sub<Coord>>::Output
impl Sub<Size> for Size
type Output = Size
The resulting type after applying the -
operator.
fn sub(self, size: Size) -> <Size as Sub<Size>>::Output
impl<'a> Sub<Size> for &'a 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
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>,