pub struct Size<T> {
pub width: T,
pub height: T,
}
Expand description
The width and height of a Rect
Fields§
§width: T
The x extent of the rectangle
height: T
The y extent of the rectangle
Implementations§
Source§impl<T> Size<T>
impl<T> Size<T>
Sourcepub fn get_abs(self, axis: AbsoluteAxis) -> T
pub fn get_abs(self, axis: AbsoluteAxis) -> T
Get either the width or height depending on the AbsoluteAxis passed in
Source§impl<T> Size<T>
impl<T> Size<T>
Sourcepub fn map<R, F>(self, f: F) -> Size<R>where
F: Fn(T) -> R,
pub fn map<R, F>(self, f: F) -> Size<R>where
F: Fn(T) -> R,
Applies the function f
to both the width and height
This is used to transform a Size<T>
into a Size<R>
.
Sourcepub fn map_width<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
pub fn map_width<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
Applies the function f
to the width
Sourcepub fn map_height<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
pub fn map_height<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
Applies the function f
to the height
Source§impl Size<Option<f32>>
impl Size<Option<f32>>
Sourcepub const fn new(width: f32, height: f32) -> Size<Option<f32>>
pub const fn new(width: f32, height: f32) -> Size<Option<f32>>
A Size<Option<f32>>
with Some(width)
and Some(height)
as parameters
Sourcepub fn maybe_apply_aspect_ratio(
self,
aspect_ratio: Option<f32>,
) -> Size<Option<f32>>
pub fn maybe_apply_aspect_ratio( self, aspect_ratio: Option<f32>, ) -> Size<Option<f32>>
Applies aspect_ratio (if one is supplied) to the Size:
- If width is
Some
but height isNone
, then height is computed from width and aspect_ratio - If height is
Some
but width isNone
, then width is computed from height and aspect_ratio
If aspect_ratio is None
then this function simply returns self.
Source§impl<T> Size<Option<T>>
impl<T> Size<Option<T>>
Sourcepub fn unwrap_or(self, alt: Size<T>) -> Size<T>
pub fn unwrap_or(self, alt: Size<T>) -> Size<T>
Performs Option::unwrap_or on each component separately
Sourcepub fn or(self, alt: Size<Option<T>>) -> Size<Option<T>>
pub fn or(self, alt: Size<Option<T>>) -> Size<Option<T>>
Performs Option::or on each component separately
Sourcepub fn both_axis_defined(&self) -> bool
pub fn both_axis_defined(&self) -> bool
Return true if both components are Some, else false.
Source§impl Size<Dimension>
impl Size<Dimension>
Sourcepub const fn from_points(width: f32, height: f32) -> Size<Dimension>
pub const fn from_points(width: f32, height: f32) -> Size<Dimension>
Generates a Size<Dimension>
using Dimension::Points
values
Sourcepub const fn from_percent(width: f32, height: f32) -> Size<Dimension>
pub const fn from_percent(width: f32, height: f32) -> Size<Dimension>
Generates a Size<Dimension>
using Dimension::Percent
values
Source§impl Size<AvailableSpace>
impl Size<AvailableSpace>
Source§impl<T> Size<T>where
T: TaffyMinContent,
impl<T> Size<T>where
T: TaffyMinContent,
Sourcepub const fn min_content() -> Size<T>
pub const fn min_content() -> Size<T>
Returns a Size where both the width and height values are the min_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)
Source§impl<T> Size<T>where
T: TaffyMaxContent,
impl<T> Size<T>where
T: TaffyMaxContent,
Sourcepub const fn max_content() -> Size<T>
pub const fn max_content() -> Size<T>
Returns a Size where both the width and height values are the max_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)
Source§impl<T> Size<T>where
T: TaffyFitContent,
impl<T> Size<T>where
T: TaffyFitContent,
Sourcepub fn fit_content(argument: LengthPercentage) -> Size<T>
pub fn fit_content(argument: LengthPercentage) -> Size<T>
Returns a Size where both the width and height values are the constant fit_content value of the contained type (e.g. 2.1, Some(2.1), or Dimension::Points(2.1))
Source§impl<T> Size<T>where
T: FromPoints,
impl<T> Size<T>where
T: FromPoints,
Trait Implementations§
Source§impl<T> FromPercent for Size<T>where
T: FromPercent,
impl<T> FromPercent for Size<T>where
T: FromPercent,
Source§impl<T> FromPoints for Size<T>where
T: FromPoints,
impl<T> FromPoints for Size<T>where
T: FromPoints,
Source§impl<T> TaffyFitContent for Size<T>where
T: TaffyFitContent,
impl<T> TaffyFitContent for Size<T>where
T: TaffyFitContent,
Source§fn fit_content(argument: LengthPercentage) -> Size<T>
fn fit_content(argument: LengthPercentage) -> Size<T>
Source§impl<T> TaffyMaxContent for Size<T>where
T: TaffyMaxContent,
impl<T> TaffyMaxContent for Size<T>where
T: TaffyMaxContent,
Source§const MAX_CONTENT: Size<T>
const MAX_CONTENT: Size<T>
Source§impl<T> TaffyMinContent for Size<T>where
T: TaffyMinContent,
impl<T> TaffyMinContent for Size<T>where
T: TaffyMinContent,
Source§const MIN_CONTENT: Size<T>
const MIN_CONTENT: Size<T>
impl<T> Copy for Size<T>where
T: Copy,
impl<T> Eq for Size<T>where
T: Eq,
impl<T> StructuralPartialEq for Size<T>
Auto Trait Implementations§
impl<T> Freeze for Size<T>where
T: Freeze,
impl<T> RefUnwindSafe for Size<T>where
T: RefUnwindSafe,
impl<T> Send for Size<T>where
T: Send,
impl<T> Sync for Size<T>where
T: Sync,
impl<T> Unpin for Size<T>where
T: Unpin,
impl<T> UnwindSafe for Size<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more