Struct primitives::foundation::Size
source · [−]#[repr(C)]pub struct Size<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
sourceimpl<T> Size2D<T>
impl<T> Size2D<T>
sourcepub fn zero() -> Self where
T: Zero,
pub fn zero() -> Self where
T: Zero,
The same as Zero::zero()
but available without importing trait.
sourcepub fn splat(v: T) -> Self where
T: Clone,
pub fn splat(v: T) -> Self where
T: Clone,
Constructor setting all components to the same value.
sourcepub fn from_untyped(p: Size2D<T>) -> Self
pub fn from_untyped(p: Size2D<T>) -> Self
Tag a unitless value with units.
sourceimpl<T: Copy> Size2D<T>
impl<T: Copy> Size2D<T>
sourcepub fn to_array(self) -> [T; 2]
pub fn to_array(self) -> [T; 2]
Return this size as an array of two elements (width, then height).
sourcepub fn to_tuple(self) -> (T, T)
pub fn to_tuple(self) -> (T, T)
Return this size as a tuple of two elements (width, then height).
Trait Implementations
sourceimpl<T: AddAssign> AddAssign<Size2D<T>> for Size2D<T>
impl<T: AddAssign> AddAssign<Size2D<T>> for Size2D<T>
sourcefn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the +=
operation. Read more
sourceimpl<T: Copy + DivAssign> DivAssign<T> for Size2D<T>
impl<T: Copy + DivAssign> DivAssign<T> for Size2D<T>
sourcefn div_assign(&mut self, other: T)
fn div_assign(&mut self, other: T)
Performs the /=
operation. Read more
sourceimpl<T: Copy + MulAssign> MulAssign<T> for Size2D<T>
impl<T: Copy + MulAssign> MulAssign<T> for Size2D<T>
sourcefn mul_assign(&mut self, other: T)
fn mul_assign(&mut self, other: T)
Performs the *=
operation. Read more
sourceimpl<T: SubAssign> SubAssign<Size2D<T>> for Size2D<T>
impl<T: SubAssign> SubAssign<Size2D<T>> for Size2D<T>
sourcefn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the -=
operation. Read more
impl<T: Copy> Copy for Size2D<T>
impl<T> Eq for Size2D<T> where
T: Eq,
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more