pub struct Size<Unit> {
pub width: Unit,
pub height: Unit,
}
Expand description
A width and a height measurement.
Fields§
§width: Unit
The width component
height: Unit
The height component
Implementations§
source§impl<Unit> Size<Unit>
impl<Unit> Size<Unit>
sourcepub const fn new(width: Unit, height: Unit) -> Self
pub const fn new(width: Unit, height: Unit) -> Self
Returns a new size of the given width
and height
.
sourcepub fn squared(dimension: Unit) -> Selfwhere
Unit: Clone,
pub fn squared(dimension: Unit) -> Selfwhere
Unit: Clone,
Returns a new size using dimension
for both width and height.
sourcepub fn cast<NewUnit>(self) -> Size<NewUnit>where
NewUnit: From<Unit>,
pub fn cast<NewUnit>(self) -> Size<NewUnit>where
NewUnit: From<Unit>,
Converts the contents of this size to NewUnit
using From
.
sourcepub fn map<NewUnit>(self, map: impl FnMut(Unit) -> NewUnit) -> Size<NewUnit>
pub fn map<NewUnit>(self, map: impl FnMut(Unit) -> NewUnit) -> Size<NewUnit>
Maps each component to map
and returns a new value with the mapped
components.
Trait Implementations§
source§impl<Unit> AddAssign<Point<Unit>> for Size<Unit>where
Unit: AddAssign,
impl<Unit> AddAssign<Point<Unit>> for Size<Unit>where
Unit: AddAssign,
source§fn add_assign(&mut self, rhs: Point<Unit>)
fn add_assign(&mut self, rhs: Point<Unit>)
Performs the
+=
operation. Read moresource§impl<Unit> AddAssign<Size<Unit>> for Point<Unit>where
Unit: AddAssign,
impl<Unit> AddAssign<Size<Unit>> for Point<Unit>where
Unit: AddAssign,
source§fn add_assign(&mut self, rhs: Size<Unit>)
fn add_assign(&mut self, rhs: Size<Unit>)
Performs the
+=
operation. Read moresource§impl<Unit> AddAssign<Unit> for Size<Unit>
impl<Unit> AddAssign<Unit> for Size<Unit>
source§fn add_assign(&mut self, rhs: Unit)
fn add_assign(&mut self, rhs: Unit)
Performs the
+=
operation. Read moresource§impl<Unit> AddAssign for Size<Unit>where
Unit: AddAssign,
impl<Unit> AddAssign for Size<Unit>where
Unit: AddAssign,
source§fn add_assign(&mut self, rhs: Size<Unit>)
fn add_assign(&mut self, rhs: Size<Unit>)
Performs the
+=
operation. Read moresource§impl<Unit> DivAssign<Point<Unit>> for Size<Unit>where
Unit: DivAssign,
impl<Unit> DivAssign<Point<Unit>> for Size<Unit>where
Unit: DivAssign,
source§fn div_assign(&mut self, rhs: Point<Unit>)
fn div_assign(&mut self, rhs: Point<Unit>)
Performs the
/=
operation. Read moresource§impl<Unit> DivAssign<Size<Unit>> for Point<Unit>where
Unit: DivAssign,
impl<Unit> DivAssign<Size<Unit>> for Point<Unit>where
Unit: DivAssign,
source§fn div_assign(&mut self, rhs: Size<Unit>)
fn div_assign(&mut self, rhs: Size<Unit>)
Performs the
/=
operation. Read moresource§impl<Unit> DivAssign<Unit> for Size<Unit>
impl<Unit> DivAssign<Unit> for Size<Unit>
source§fn div_assign(&mut self, rhs: Unit)
fn div_assign(&mut self, rhs: Unit)
Performs the
/=
operation. Read moresource§impl<Unit> DivAssign for Size<Unit>where
Unit: DivAssign,
impl<Unit> DivAssign for Size<Unit>where
Unit: DivAssign,
source§fn div_assign(&mut self, rhs: Size<Unit>)
fn div_assign(&mut self, rhs: Size<Unit>)
Performs the
/=
operation. Read moresource§impl<T> FloatConversion for Size<T>where
T: FloatConversion,
impl<T> FloatConversion for Size<T>where
T: FloatConversion,
§type Float = Size<<T as FloatConversion>::Float>
type Float = Size<<T as FloatConversion>::Float>
The type that represents this type in floating point form.
source§fn into_float(self) -> Self::Float
fn into_float(self) -> Self::Float
Returns this value in floating point form.
source§fn from_float(float: Self::Float) -> Self
fn from_float(float: Self::Float) -> Self
Converts from floating point to this form.
source§impl<Unit> FromComponents<Unit> for Size<Unit>
impl<Unit> FromComponents<Unit> for Size<Unit>
source§fn from_components(components: (Unit, Unit)) -> Self
fn from_components(components: (Unit, Unit)) -> Self
Returns a new instance from the 2d vector components provided.
source§fn from_vec<Type>(other: Type) -> Selfwhere
Type: IntoComponents<Unit>,
fn from_vec<Type>(other: Type) -> Selfwhere
Type: IntoComponents<Unit>,
Converts this type to another type using
FromComponents
and
IntoComponents
.source§impl<Unit> IntoComponents<Unit> for Size<Unit>
impl<Unit> IntoComponents<Unit> for Size<Unit>
source§fn into_components(self) -> (Unit, Unit)
fn into_components(self) -> (Unit, Unit)
Extracts this type’s 2d vector components.
source§fn to_vec<Type>(self) -> Typewhere
Type: FromComponents<Unit>,
fn to_vec<Type>(self) -> Typewhere
Type: FromComponents<Unit>,
Converts this type to another type using
FromComponents
and
IntoComponents
.source§impl<Unit> IntoSigned for Size<Unit>where
Unit: IntoSigned,
impl<Unit> IntoSigned for Size<Unit>where
Unit: IntoSigned,
§type Signed = Size<<Unit as IntoSigned>::Signed>
type Signed = Size<<Unit as IntoSigned>::Signed>
The signed representation of this type.
source§fn into_signed(self) -> Self::Signed
fn into_signed(self) -> Self::Signed
Returns this value as an unsigned value. Values that are larger than can
fit in an
i32
are converted to i32::MAX
.source§impl<Unit> IntoUnsigned for Size<Unit>where
Unit: IntoUnsigned,
impl<Unit> IntoUnsigned for Size<Unit>where
Unit: IntoUnsigned,
§type Unsigned = Size<<Unit as IntoUnsigned>::Unsigned>
type Unsigned = Size<<Unit as IntoUnsigned>::Unsigned>
The unsigned representation of this type.
source§fn into_unsigned(self) -> Self::Unsigned
fn into_unsigned(self) -> Self::Unsigned
Returns this value as an unsigned value. Negative values will be
converted to 0.
source§impl<Unit> MulAssign<Point<Unit>> for Size<Unit>where
Unit: MulAssign,
impl<Unit> MulAssign<Point<Unit>> for Size<Unit>where
Unit: MulAssign,
source§fn mul_assign(&mut self, rhs: Point<Unit>)
fn mul_assign(&mut self, rhs: Point<Unit>)
Performs the
*=
operation. Read moresource§impl<Unit> MulAssign<Size<Unit>> for Point<Unit>where
Unit: MulAssign,
impl<Unit> MulAssign<Size<Unit>> for Point<Unit>where
Unit: MulAssign,
source§fn mul_assign(&mut self, rhs: Size<Unit>)
fn mul_assign(&mut self, rhs: Size<Unit>)
Performs the
*=
operation. Read moresource§impl<Unit> MulAssign<Unit> for Size<Unit>
impl<Unit> MulAssign<Unit> for Size<Unit>
source§fn mul_assign(&mut self, rhs: Unit)
fn mul_assign(&mut self, rhs: Unit)
Performs the
*=
operation. Read moresource§impl<Unit> MulAssign for Size<Unit>where
Unit: MulAssign,
impl<Unit> MulAssign for Size<Unit>where
Unit: MulAssign,
source§fn mul_assign(&mut self, rhs: Size<Unit>)
fn mul_assign(&mut self, rhs: Size<Unit>)
Performs the
*=
operation. Read moresource§impl<Unit> Ord for Size<Unit>
impl<Unit> Ord for Size<Unit>
source§impl<Unit: PartialEq> PartialEq for Size<Unit>
impl<Unit: PartialEq> PartialEq for Size<Unit>
source§impl<Unit> PartialOrd for Size<Unit>
impl<Unit> PartialOrd for Size<Unit>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl<Unit> RemAssign<Point<Unit>> for Size<Unit>where
Unit: RemAssign,
impl<Unit> RemAssign<Point<Unit>> for Size<Unit>where
Unit: RemAssign,
source§fn rem_assign(&mut self, rhs: Point<Unit>)
fn rem_assign(&mut self, rhs: Point<Unit>)
Performs the
%=
operation. Read moresource§impl<Unit> RemAssign<Size<Unit>> for Point<Unit>where
Unit: RemAssign,
impl<Unit> RemAssign<Size<Unit>> for Point<Unit>where
Unit: RemAssign,
source§fn rem_assign(&mut self, rhs: Size<Unit>)
fn rem_assign(&mut self, rhs: Size<Unit>)
Performs the
%=
operation. Read moresource§impl<Unit> RemAssign<Unit> for Size<Unit>
impl<Unit> RemAssign<Unit> for Size<Unit>
source§fn rem_assign(&mut self, rhs: Unit)
fn rem_assign(&mut self, rhs: Unit)
Performs the
%=
operation. Read moresource§impl<Unit> RemAssign for Size<Unit>where
Unit: RemAssign,
impl<Unit> RemAssign for Size<Unit>where
Unit: RemAssign,
source§fn rem_assign(&mut self, rhs: Size<Unit>)
fn rem_assign(&mut self, rhs: Size<Unit>)
Performs the
%=
operation. Read moresource§impl<Unit> ScreenScale for Size<Unit>
impl<Unit> ScreenScale for Size<Unit>
source§fn into_px(self, scale: Fraction) -> Self::Px
fn into_px(self, scale: Fraction) -> Self::Px
Converts this value from its current unit into device pixels (
Px
)
using the provided scale
factor.source§fn from_px(px: Self::Px, scale: Fraction) -> Self
fn from_px(px: Self::Px, scale: Fraction) -> Self
Converts from pixels into this type, using the provided
scale
factor.source§fn into_lp(self, scale: Fraction) -> Self::Lp
fn into_lp(self, scale: Fraction) -> Self::Lp
Converts this value from its current unit into device independent pixels
(
Lp
) using the provided scale
factor.source§fn from_lp(lp: Self::Lp, scale: Fraction) -> Self
fn from_lp(lp: Self::Lp, scale: Fraction) -> Self
Converts from Lp into this type, using the provided
scale
factor.source§impl<Unit> SubAssign<Point<Unit>> for Size<Unit>where
Unit: SubAssign,
impl<Unit> SubAssign<Point<Unit>> for Size<Unit>where
Unit: SubAssign,
source§fn sub_assign(&mut self, rhs: Point<Unit>)
fn sub_assign(&mut self, rhs: Point<Unit>)
Performs the
-=
operation. Read moresource§impl<Unit> SubAssign<Size<Unit>> for Point<Unit>where
Unit: SubAssign,
impl<Unit> SubAssign<Size<Unit>> for Point<Unit>where
Unit: SubAssign,
source§fn sub_assign(&mut self, rhs: Size<Unit>)
fn sub_assign(&mut self, rhs: Size<Unit>)
Performs the
-=
operation. Read moresource§impl<Unit> SubAssign<Unit> for Size<Unit>
impl<Unit> SubAssign<Unit> for Size<Unit>
source§fn sub_assign(&mut self, rhs: Unit)
fn sub_assign(&mut self, rhs: Unit)
Performs the
-=
operation. Read moresource§impl<Unit> SubAssign for Size<Unit>where
Unit: SubAssign,
impl<Unit> SubAssign for Size<Unit>where
Unit: SubAssign,
source§fn sub_assign(&mut self, rhs: Size<Unit>)
fn sub_assign(&mut self, rhs: Size<Unit>)
Performs the
-=
operation. Read moreimpl<Unit: Copy> Copy for Size<Unit>
impl<Unit: Eq> Eq for Size<Unit>
impl<Unit> StructuralPartialEq for Size<Unit>
Auto Trait Implementations§
impl<Unit> Freeze for Size<Unit>where
Unit: Freeze,
impl<Unit> RefUnwindSafe for Size<Unit>where
Unit: RefUnwindSafe,
impl<Unit> Send for Size<Unit>where
Unit: Send,
impl<Unit> Sync for Size<Unit>where
Unit: Sync,
impl<Unit> Unpin for Size<Unit>where
Unit: Unpin,
impl<Unit> UnwindSafe for Size<Unit>where
Unit: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<Unit> IntoComponents<Unit> for Unitwhere
Unit: Copy,
impl<Unit> IntoComponents<Unit> for Unitwhere
Unit: Copy,
source§fn into_components(self) -> (Unit, Unit)
fn into_components(self) -> (Unit, Unit)
Extracts this type’s 2d vector components.
source§fn to_vec<Type>(self) -> Typewhere
Type: FromComponents<Unit>,
fn to_vec<Type>(self) -> Typewhere
Type: FromComponents<Unit>,
Converts this type to another type using
FromComponents
and
IntoComponents
.source§impl<T> Lp2D for Twhere
T: FromComponents<Lp>,
impl<T> Lp2D for Twhere
T: FromComponents<Lp>,
source§fn points(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
fn points(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
Returns a new value containing the x and y components converted into
Lp
using Lp::points
/Lp::points_f
.source§fn cm(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
fn cm(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
source§fn mm(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
fn mm(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
source§fn inches(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
fn inches(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
Returns a new value containing the x and y components converted into
Lp
using Lp::inches
/Lp::inches_f
.