Size2D

Struct Size2D 

Source
#[repr(C)]
pub struct Size2D<T> { pub width: T, pub height: T, }
Expand description

A 2d size tagged with a unit.

Fields§

§width: T

The extent of the element in the U units along the x axis (usually horizontal).

§height: T

The extent of the element in the U units along the y axis (usually vertical).

Implementations§

Source§

impl<T> Size2D<T>

Source

pub fn zero() -> Self
where T: Zero,

The same as Zero::zero() but available without importing trait.

Source

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

Constructor taking scalar values.

Source

pub fn splat(v: T) -> Self
where T: Clone,

Constructor setting all components to the same value.

Source

pub fn from_untyped(p: Size2D<T>) -> Self

Tag a unitless value with units.

Source§

impl<T: Copy> Size2D<T>

Source

pub fn to_array(self) -> [T; 2]

Return this size as an array of two elements (width, then height).

Source

pub fn to_tuple(self) -> (T, T)

Return this size as a tuple of two elements (width, then height).

Source

pub fn area(self) -> T::Output
where T: Mul,

Returns result of multiplication of both components

Source

pub fn lerp(self, other: Self, t: T) -> Self
where T: One + Sub<Output = T> + Mul<Output = T> + Add<Output = T>,

Linearly interpolate each component between this size and another size.

Trait Implementations§

Source§

impl<T: Copy + Add<T, Output = T>> Add<&Size2D<T>> for Size2D<T>

Source§

type Output = Size2D<T>

The resulting type after applying the + operator.
Source§

fn add(self, other: &Self) -> Self

Performs the + operation. Read more
Source§

impl<T: Add> Add for Size2D<T>

Source§

type Output = Size2D<<T as Add>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: AddAssign> AddAssign for Size2D<T>

Source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
Source§

impl<T: Clone> Clone for Size2D<T>

Source§

fn clone(&self) -> Self

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<T: Debug> Debug for Size2D<T>

Source§

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

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

impl<T: Default> Default for Size2D<T>

Source§

fn default() -> Self

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

impl<T: Copy + Div> Div<T> for Size2D<T>

Source§

type Output = Size2D<<T as Div>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, scale: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: Copy + DivAssign> DivAssign<T> for Size2D<T>

Source§

fn div_assign(&mut self, other: T)

Performs the /= operation. Read more
Source§

impl<T> From<[T; 2]> for Size2D<T>

Source§

fn from([w, h]: [T; 2]) -> Self

Converts to this type from the input type.
Source§

impl<T> From<(T, T)> for Size2D<T>

Source§

fn from(tuple: (T, T)) -> Self

Converts to this type from the input type.
Source§

impl<T> Hash for Size2D<T>
where T: Hash,

Source§

fn hash<H: Hasher>(&self, h: &mut H)

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<T> Into<[T; 2]> for Size2D<T>

Source§

fn into(self) -> [T; 2]

Converts this type into the (usually inferred) input type.
Source§

impl<T> Into<(T, T)> for Size2D<T>

Source§

fn into(self) -> (T, T)

Converts this type into the (usually inferred) input type.
Source§

impl<T: Copy + Mul> Mul<T> for Size2D<T>

Source§

type Output = Size2D<<T as Mul>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, scale: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: Copy + MulAssign> MulAssign<T> for Size2D<T>

Source§

fn mul_assign(&mut self, other: T)

Performs the *= operation. Read more
Source§

impl<T: Neg> Neg for Size2D<T>

Source§

type Output = Size2D<<T as Neg>::Output>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T> PartialEq for Size2D<T>
where T: PartialEq,

Source§

fn eq(&self, other: &Self) -> 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<T: Sub> Sub for Size2D<T>

Source§

type Output = Size2D<<T as Sub>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: SubAssign> SubAssign for Size2D<T>

Source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
Source§

impl<T: Add<Output = T> + Zero> Sum for Size2D<T>

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<T: Zero> Zero for Size2D<T>

Source§

fn zero() -> Self

Creates a structure with zero values.
Source§

impl<T: Copy> Copy for Size2D<T>

Source§

impl<T> Eq for Size2D<T>
where T: Eq,

Auto Trait Implementations§

§

impl<T> Freeze for Size2D<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Size2D<T>
where T: RefUnwindSafe,

§

impl<T> Send for Size2D<T>
where T: Send,

§

impl<T> Sync for Size2D<T>
where T: Sync,

§

impl<T> Unpin for Size2D<T>
where T: Unpin,

§

impl<T> UnwindSafe for Size2D<T>
where T: UnwindSafe,

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<Fr, To> IntoColor<To> for Fr
where To: FromColor<Fr>,

Source§

fn into_color(self) -> To

Convert into color
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.