#[repr(C)]pub struct TypedSize2D<T, U> {
pub width: T,
pub height: T,
/* private fields */
}Expand description
A 2d size tagged with a unit.
Fields§
§width: T§height: TImplementations§
Source§impl<T, U> TypedSize2D<T, U>
impl<T, U> TypedSize2D<T, U>
Source§impl<T: Clone, U> TypedSize2D<T, U>
impl<T: Clone, U> TypedSize2D<T, U>
Sourcepub fn from_lengths(width: Length<T, U>, height: Length<T, U>) -> Self
pub fn from_lengths(width: Length<T, U>, height: Length<T, U>) -> Self
Constructor taking scalar strongly typed lengths.
Source§impl<T: Round, U> TypedSize2D<T, U>
impl<T: Round, U> TypedSize2D<T, U>
Source§impl<T: Ceil, U> TypedSize2D<T, U>
impl<T: Ceil, U> TypedSize2D<T, U>
Source§impl<T: Floor, U> TypedSize2D<T, U>
impl<T: Floor, U> TypedSize2D<T, U>
Source§impl<T, U> TypedSize2D<T, U>
impl<T, U> TypedSize2D<T, U>
Source§impl<T: Zero + PartialOrd, U> TypedSize2D<T, U>
impl<T: Zero + PartialOrd, U> TypedSize2D<T, U>
pub fn is_empty_or_negative(&self) -> bool
Source§impl<T: Copy, U> TypedSize2D<T, U>
impl<T: Copy, U> TypedSize2D<T, U>
Sourcepub fn width_typed(&self) -> Length<T, U>
pub fn width_typed(&self) -> Length<T, U>
Returns self.width as a Length carrying the unit.
Sourcepub fn height_typed(&self) -> Length<T, U>
pub fn height_typed(&self) -> Length<T, U>
Returns self.height as a Length carrying the unit.
pub fn to_array(&self) -> [T; 2]
pub fn to_tuple(&self) -> (T, T)
pub fn to_vector(&self) -> TypedVector2D<T, U>
Sourcepub fn to_untyped(&self) -> Size2D<T>
pub fn to_untyped(&self) -> Size2D<T>
Drop the units, preserving only the numeric value.
Sourcepub fn from_untyped(p: &Size2D<T>) -> Self
pub fn from_untyped(p: &Size2D<T>) -> Self
Tag a unitless value with units.
Source§impl<T: NumCast + Copy, Unit> TypedSize2D<T, Unit>
impl<T: NumCast + Copy, Unit> TypedSize2D<T, Unit>
Sourcepub fn cast<NewT: NumCast + Copy>(&self) -> TypedSize2D<NewT, Unit>
pub fn cast<NewT: NumCast + Copy>(&self) -> TypedSize2D<NewT, Unit>
Cast from one numeric representation to another, preserving the units.
When casting from floating point to integer coordinates, the decimals are truncated
as one would expect from a simple cast, but this behavior does not always make sense
geometrically. Consider using round(), ceil() or floor() before casting.
Sourcepub fn try_cast<NewT: NumCast + Copy>(&self) -> Option<TypedSize2D<NewT, Unit>>
pub fn try_cast<NewT: NumCast + Copy>(&self) -> Option<TypedSize2D<NewT, Unit>>
Fallible cast from one numeric representation to another, preserving the units.
When casting from floating point to integer coordinates, the decimals are truncated
as one would expect from a simple cast, but this behavior does not always make sense
geometrically. Consider using round(), ceil() or floor() before casting.
Sourcepub fn to_f32(&self) -> TypedSize2D<f32, Unit>
pub fn to_f32(&self) -> TypedSize2D<f32, Unit>
Cast into an f32 size.
Sourcepub fn to_f64(&self) -> TypedSize2D<f64, Unit>
pub fn to_f64(&self) -> TypedSize2D<f64, Unit>
Cast into an f64 size.
Sourcepub fn to_usize(&self) -> TypedSize2D<usize, Unit>
pub fn to_usize(&self) -> TypedSize2D<usize, Unit>
Cast into an uint size, truncating decimals if any.
When casting from floating point sizes, it is worth considering whether
to round(), ceil() or floor() before the cast in order to obtain
the desired conversion behavior.
Sourcepub fn to_u32(&self) -> TypedSize2D<u32, Unit>
pub fn to_u32(&self) -> TypedSize2D<u32, Unit>
Cast into an u32 size, truncating decimals if any.
When casting from floating point sizes, it is worth considering whether
to round(), ceil() or floor() before the cast in order to obtain
the desired conversion behavior.
Sourcepub fn to_i32(&self) -> TypedSize2D<i32, Unit>
pub fn to_i32(&self) -> TypedSize2D<i32, Unit>
Cast into an i32 size, truncating decimals if any.
When casting from floating point sizes, it is worth considering whether
to round(), ceil() or floor() before the cast in order to obtain
the desired conversion behavior.
Sourcepub fn to_i64(&self) -> TypedSize2D<i64, Unit>
pub fn to_i64(&self) -> TypedSize2D<i64, Unit>
Cast into an i64 size, truncating decimals if any.
When casting from floating point sizes, it is worth considering whether
to round(), ceil() or floor() before the cast in order to obtain
the desired conversion behavior.
Source§impl<T, U> TypedSize2D<T, U>where
T: Signed,
impl<T, U> TypedSize2D<T, U>where
T: Signed,
pub fn abs(&self) -> Self
pub fn is_positive(&self) -> bool
Source§impl<T: PartialOrd, U> TypedSize2D<T, U>
impl<T: PartialOrd, U> TypedSize2D<T, U>
pub fn greater_than(&self, other: &Self) -> BoolVector2D
pub fn lower_than(&self, other: &Self) -> BoolVector2D
Source§impl<T: PartialEq, U> TypedSize2D<T, U>
impl<T: PartialEq, U> TypedSize2D<T, U>
pub fn equal(&self, other: &Self) -> BoolVector2D
pub fn not_equal(&self, other: &Self) -> BoolVector2D
Trait Implementations§
Source§impl<T: Copy + Add<T, Output = T>, U> Add<TypedSize2D<T, U>> for TypedPoint2D<T, U>
impl<T: Copy + Add<T, Output = T>, U> Add<TypedSize2D<T, U>> for TypedPoint2D<T, U>
Source§type Output = TypedPoint2D<T, U>
type Output = TypedPoint2D<T, U>
+ operator.Source§fn add(self, other: TypedSize2D<T, U>) -> Self
fn add(self, other: TypedSize2D<T, U>) -> Self
+ operation. Read moreSource§impl<T, U> Clone for TypedSize2D<T, U>where
T: Clone,
impl<T, U> Clone for TypedSize2D<T, U>where
T: Clone,
Source§impl<T: Debug, U> Debug for TypedSize2D<T, U>
impl<T: Debug, U> Debug for TypedSize2D<T, U>
Source§impl<T: Default, U> Default for TypedSize2D<T, U>
impl<T: Default, U> Default for TypedSize2D<T, U>
Source§impl<'de, T, U> Deserialize<'de> for TypedSize2D<T, U>where
T: Deserialize<'de>,
impl<'de, T, U> Deserialize<'de> for TypedSize2D<T, U>where
T: Deserialize<'de>,
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<T: Display, U> Display for TypedSize2D<T, U>
impl<T: Display, U> Display for TypedSize2D<T, U>
Source§impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedSize2D<T, U2>
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedSize2D<T, U2>
Source§type Output = TypedSize2D<T, U1>
type Output = TypedSize2D<T, U1>
/ operator.Source§fn div(self, scale: TypedScale<T, U1, U2>) -> TypedSize2D<T, U1>
fn div(self, scale: TypedScale<T, U1, U2>) -> TypedSize2D<T, U1>
/ operation. Read moreSource§impl<T, U> From<TypedSize2D<T, U>> for TypedBox2D<T, U>
impl<T, U> From<TypedSize2D<T, U>> for TypedBox2D<T, U>
Source§fn from(b: TypedSize2D<T, U>) -> Self
fn from(b: TypedSize2D<T, U>) -> Self
Source§impl<T, U> From<TypedSize2D<T, U>> for TypedRect<T, U>
impl<T, U> From<TypedSize2D<T, U>> for TypedRect<T, U>
Source§fn from(size: TypedSize2D<T, U>) -> Self
fn from(size: TypedSize2D<T, U>) -> Self
Source§impl<T, U> Hash for TypedSize2D<T, U>where
T: Hash,
impl<T, U> Hash for TypedSize2D<T, U>where
T: Hash,
Source§impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedSize2D<T, U1>
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedSize2D<T, U1>
Source§type Output = TypedSize2D<T, U2>
type Output = TypedSize2D<T, U2>
* operator.Source§fn mul(self, scale: TypedScale<T, U1, U2>) -> TypedSize2D<T, U2>
fn mul(self, scale: TypedScale<T, U1, U2>) -> TypedSize2D<T, U2>
* operation. Read more