Struct cuadra::Position16

source ·
pub struct Position16 { /* private fields */ }
Expand description

A 2D position using a clamped i16.

Implementations§

source§

impl Position16

source

pub const fn new(x: i16, y: i16) -> Self

Defines a new Position with the given dimensions.

source

pub const fn x(&self) -> i16

Get x.

source

pub const fn y(&self) -> i16

Get y.

source

pub fn set_x(&mut self, x: i16)

Set x.

source

pub fn set_y(&mut self, y: i16)

Set y.

source

pub fn swap(&mut self)

Swaps the x, y values.

source

pub const fn swapped(&self) -> Position16

Returns a new Position16 with the x, y values swapped.

source§

impl Position16

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source§

impl Position16

source

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

Saturating, clamped addition of two Position16.

source

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

Wrapping, clamped addition of two Position16.

source

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

Checked, clamped addition of two Position16.

source

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

Saturating, clamped addition of two Position16.

source

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

Wrapping, clamped addition of two Position16.

source

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

Checked, clamped addition of two Position16.

source

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

Saturating, clamped multiplication of two Position16.

source

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

Wrapping, clamped multiplication of two Position16.

source

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

Checked, clamped multiplication of two Position16.

source

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

Saturating, clamped division of two Position16.

source

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

Wrapping, clamped division of two Position16.

source

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

Checked, clamped division of two Position16.

source

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

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

source

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

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

source

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

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

source

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

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

source

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

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

source

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

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

source

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

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

source

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

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

source

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

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

source

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

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

source

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

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

source

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

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

Trait Implementations§

source§

impl Add<Position16> for Position16

source§

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

Saturating, clamped addition.

§

type Output = Position16

The resulting type after applying the + operator.
source§

impl Add<i16> for Position16

source§

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

Saturating, clamped addition.

§

type Output = Position16

The resulting type after applying the + operator.
source§

impl Clone for Position16

source§

fn clone(&self) -> Position16

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 Position16

source§

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

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

impl Default for Position16

source§

fn default() -> Position16

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

impl Display for Position16

source§

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

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

impl Div<Position16> for Position16

source§

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

Saturating, clamped division.

§

type Output = Position16

The resulting type after applying the / operator.
source§

impl Div<i16> for Position16

source§

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

Saturating, clamped division.

§

type Output = Position16

The resulting type after applying the / operator.
source§

impl From<(i16, i16)> for Position16

source§

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

Converts to this type from the input type.
source§

impl From<(i32, i32)> for Position16

source§

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

Converts to this type from the input type.
source§

impl From<(u16, u16)> for Position16

source§

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

Converts to this type from the input type.
source§

impl From<(u32, u32)> for Position16

source§

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

Converts to this type from the input type.
source§

impl From<(usize, usize)> for Position16

source§

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

Converts to this type from the input type.
source§

impl From<Position16> for (i16, i16)

source§

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

Converts to this type from the input type.
source§

impl From<Position16> for (i32, i32)

source§

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

Converts to this type from the input type.
source§

impl From<Position16> for (u16, u16)

source§

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

Converts to this type from the input type.
source§

impl From<Position16> for (u32, u32)

source§

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

Converts to this type from the input type.
source§

impl From<Position16> for (usize, usize)

source§

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

Converts to this type from the input type.
source§

impl Mul<Position16> for Position16

source§

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

Saturating, clamped multiplication.

§

type Output = Position16

The resulting type after applying the * operator.
source§

impl Mul<i16> for Position16

source§

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

Saturating, clamped multiplication.

§

type Output = Position16

The resulting type after applying the * operator.
source§

impl Ord for Position16

source§

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

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

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

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

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

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

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

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

impl PartialEq<Position16> for Position16

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Position16> for Position16

source§

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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<Position16> for Position16

source§

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

Saturating, clamped addition.

§

type Output = Position16

The resulting type after applying the - operator.
source§

impl Sub<i16> for Position16

source§

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

Saturating, clamped addition.

§

type Output = Position16

The resulting type after applying the - operator.
source§

impl Copy for Position16

source§

impl Eq for Position16

source§

impl StructuralEq for Position16

source§

impl StructuralPartialEq for Position16

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.