Size16

Struct Size16 

Source
pub struct Size16 { /* private fields */ }
Expand description

A 2D size using a positive clamped i16.

Implementations§

Source§

impl Size16

Source

pub const fn new(width: i16, height: i16) -> Self

Defines a new Size with the given dimensions, which has to be at least 1.

Source

pub const fn w(&self) -> i16

Get the width.

Source

pub const fn h(&self) -> i16

Get the height.

Source

pub fn set_w(&mut self, width: i16)

Set the width.

Source

pub fn set_h(&mut self, height: i16)

Set the height.

Source

pub fn swap(&mut self)

Swaps the w, h values.

Source

pub const fn swapped(&self) -> Size16

Returns a new Size16 with the w, h values swapped.

Source§

impl Size16

§conversions

Source

pub const fn as_tuple(&self) -> (i16, i16)

Source

pub const fn from_tuple(tup: (i16, i16)) -> Size16

Source

pub const fn as_tuple_i32(&self) -> (i32, i32)

Source

pub const fn from_tuple_i32(tup: (i32, i32)) -> Size16

Source

pub const fn as_tuple_u32(&self) -> (u32, u32)

Source

pub const fn from_tuple_u32(tup: (u32, u32)) -> Size16

Source

pub const fn as_tuple_u16(&self) -> (u16, u16)

Source

pub const fn from_tuple_u16(tup: (u16, u16)) -> Size16

Source

pub const fn as_tuple_i16(&self) -> (i16, i16)

Source

pub const fn from_tuple_i16(tup: (i16, i16)) -> Size16

Source

pub const fn as_tuple_usize(&self) -> (usize, usize)

Source

pub const fn from_tuple_usize(tup: (usize, usize)) -> Size16

Source§

impl Size16

§arithmetic ops.

Source

pub const fn saturating_add(&self, rhs: Size16) -> Size16

Saturating, clamped addition of two Size16.

Source

pub const fn wrapping_add(&self, rhs: Size16) -> Size16

Wrapping, clamped addition of two Size16.

Source

pub fn checked_add(&self, rhs: Size16) -> Option<Size16>

Checked, clamped addition of two Size16.

Source

pub const fn saturating_sub(&self, rhs: Size16) -> Size16

Saturating, clamped addition of two Size16.

Source

pub const fn wrapping_sub(&self, rhs: Size16) -> Size16

Wrapping, clamped addition of two Size16.

Source

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

Checked, clamped addition of two Size16.

Source

pub const fn saturating_mul(&self, rhs: Size16) -> Size16

Saturating, clamped multiplication of two Size16.

Source

pub const fn wrapping_mul(&self, rhs: Size16) -> Size16

Wrapping, clamped multiplication of two Size16.

Source

pub fn checked_mul(&self, rhs: Size16) -> Option<Size16>

Checked, clamped multiplication of two Size16.

Source

pub const fn saturating_div(&self, rhs: Size16) -> Size16

Saturating, clamped division of two Size16.

Source

pub const fn wrapping_div(&self, rhs: Size16) -> Size16

Wrapping, clamped division of two Size16.

Source

pub fn checked_div(&self, rhs: Size16) -> Option<Size16>

Checked, clamped division of two Size16.

Source

pub const fn saturating_add_value(&self, value: i16) -> Size16

Saturating, clamped addition of a Size16 with a value``.

Source

pub const fn wrapping_add_value(&self, value: i16) -> Size16

Wrapping, clamped addition of a Size16 with a value``.

Source

pub fn checked_add_value(&self, value: i16) -> Option<Size16>

Checked, clamped addition of a Size16 with a value``.

Source

pub const fn saturating_sub_value(&self, value: i16) -> Size16

Saturating, clamped substraction of a Size16 with a value``.

Source

pub const fn wrapping_sub_value(&self, value: i16) -> Size16

Wrapping, clamped substraction of a Size16 with a value``.

Source

pub fn checked_sub_value(&self, value: i16) -> Option<Size16>

Checked, clamped substraction of a Size16 with a value``.

Source

pub const fn saturating_mul_value(&self, value: i16) -> Size16

Saturating, clamped multiplication of a Size16 with a value``.

Source

pub const fn wrapping_mul_value(&self, value: i16) -> Size16

Wrapping, clamped multiplication of a Size16 with a value``.

Source

pub fn checked_mul_value(&self, value: i16) -> Option<Size16>

Checked, clamped multiplication of a Size16 with a value``.

Source

pub const fn saturating_div_value(&self, value: i16) -> Size16

Saturating, clamped division of a Size16 with a value``.

Source

pub const fn wrapping_div_value(&self, value: i16) -> Size16

Wrapping, clamped division of a Size16 with a value``.

Source

pub fn checked_div_value(&self, value: i16) -> Option<Size16>

Checked, clamped division of a Size16 with a value``.

Trait Implementations§

Source§

impl Add<i16> for Size16

Source§

fn add(self, rhs: i16) -> Self

Saturating, clamped addition.

Source§

type Output = Size16

The resulting type after applying the + operator.
Source§

impl Add for Size16

Source§

fn add(self, rhs: Self) -> Self

Saturating, clamped addition.

Source§

type Output = Size16

The resulting type after applying the + operator.
Source§

impl Clone for Size16

Source§

fn clone(&self) -> Size16

Returns a duplicate 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 Size16

Source§

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

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

impl Default for Size16

Source§

fn default() -> Size16

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

impl Display for Size16

Source§

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

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

impl Div<i16> for Size16

Source§

fn div(self, rhs: i16) -> Self

Saturating, clamped division.

Source§

type Output = Size16

The resulting type after applying the / operator.
Source§

impl Div for Size16

Source§

fn div(self, rhs: Self) -> Self

Saturating, clamped division.

Source§

type Output = Size16

The resulting type after applying the / operator.
Source§

impl From<(i16, i16)> for Size16

Source§

fn from(tup: (i16, i16)) -> Size16

Converts to this type from the input type.
Source§

impl From<(i32, i32)> for Size16

Source§

fn from(tup: (i32, i32)) -> Size16

Converts to this type from the input type.
Source§

impl From<(u16, u16)> for Size16

Source§

fn from(tup: (u16, u16)) -> Size16

Converts to this type from the input type.
Source§

impl From<(u32, u32)> for Size16

Source§

fn from(tup: (u32, u32)) -> Size16

Converts to this type from the input type.
Source§

impl From<(usize, usize)> for Size16

Source§

fn from(tup: (usize, usize)) -> Size16

Converts to this type from the input type.
Source§

impl From<Size16> for (i16, i16)

Source§

fn from(s: Size16) -> (i16, i16)

Converts to this type from the input type.
Source§

impl From<Size16> for (i32, i32)

Source§

fn from(s: Size16) -> (i32, i32)

Converts to this type from the input type.
Source§

impl From<Size16> for (u16, u16)

Source§

fn from(s: Size16) -> (u16, u16)

Converts to this type from the input type.
Source§

impl From<Size16> for (u32, u32)

Source§

fn from(s: Size16) -> (u32, u32)

Converts to this type from the input type.
Source§

impl From<Size16> for (usize, usize)

Source§

fn from(s: Size16) -> (usize, usize)

Converts to this type from the input type.
Source§

impl Mul<i16> for Size16

Source§

fn mul(self, rhs: i16) -> Self

Saturating, clamped multiplication.

Source§

type Output = Size16

The resulting type after applying the * operator.
Source§

impl Mul for Size16

Source§

fn mul(self, rhs: Self) -> Self

Saturating, clamped multiplication.

Source§

type Output = Size16

The resulting type after applying the * operator.
Source§

impl Ord for Size16

Source§

fn cmp(&self, other: &Size16) -> 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 Size16

Source§

fn eq(&self, other: &Size16) -> 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 Size16

Source§

fn partial_cmp(&self, other: &Size16) -> 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 Sub<i16> for Size16

Source§

fn sub(self, rhs: i16) -> Self

Saturating, clamped addition.

Source§

type Output = Size16

The resulting type after applying the - operator.
Source§

impl Sub for Size16

Source§

fn sub(self, rhs: Self) -> Self

Saturating, clamped addition.

Source§

type Output = Size16

The resulting type after applying the - operator.
Source§

impl Copy for Size16

Source§

impl Eq for Size16

Source§

impl StructuralPartialEq for Size16

Auto Trait Implementations§

§

impl Freeze for Size16

§

impl RefUnwindSafe for Size16

§

impl Send for Size16

§

impl Sync for Size16

§

impl Unpin for Size16

§

impl UnwindSafe for Size16

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.