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
sourcepub fn zip_map<Other, Ret, Func>(self, other: Size<Other>, f: Func) -> Size<Ret>where
Func: Fn(T, Other) -> Ret,
pub fn zip_map<Other, Ret, Func>(self, other: Size<Other>, f: Func) -> Size<Ret>where
Func: Fn(T, Other) -> Ret,
Applies the function f
to both the width and height
of this value and another passed value
sourcepub(crate) fn get(self, axis: AbstractAxis) -> T
pub(crate) fn get(self, axis: AbstractAxis) -> T
Gets the extent of the specified layout axis
Whether this is the width or height depends on the GridAxis
provided
sourcepub(crate) fn set(&mut self, axis: AbstractAxis, value: T)
pub(crate) fn set(&mut self, axis: AbstractAxis, value: T)
Sets the extent of the specified layout axis
Whether this is the width or height depends on the GridAxis
provided
source§impl Size<f32>
impl Size<f32>
sourcepub fn has_non_zero_area(self) -> bool
pub fn has_non_zero_area(self) -> bool
Return true if both width and height are greater than 0 else false
source§impl Size<Option<f32>>
impl Size<Option<f32>>
sourcepub const fn new(width: f32, height: f32) -> Self
pub const fn new(width: f32, height: f32) -> Self
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_lengths(width: f32, height: f32) -> Self
pub const fn from_lengths(width: f32, height: f32) -> Self
Generates a Size<Dimension>
using Dimension::Length
values
sourcepub const fn from_percent(width: f32, height: f32) -> Self
pub const fn from_percent(width: f32, height: f32) -> Self
Generates a Size<Dimension>
using Dimension::Percent
values
source§impl Size<AvailableSpace>
impl Size<AvailableSpace>
source§impl<T: TaffyMinContent> Size<T>
impl<T: TaffyMinContent> Size<T>
sourcepub const fn min_content() -> Self
pub const fn min_content() -> Self
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: TaffyMaxContent> Size<T>
impl<T: TaffyMaxContent> Size<T>
sourcepub const fn max_content() -> Self
pub const fn max_content() -> Self
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: TaffyFitContent> Size<T>
impl<T: TaffyFitContent> Size<T>
sourcepub fn fit_content(argument: LengthPercentage) -> Self
pub fn fit_content(argument: LengthPercentage) -> Self
Returns a Size where with width and height set to the same fit-content(…)
value
with the given argument.
source§impl<T: FromLength> Size<T>
impl<T: FromLength> Size<T>
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for Size<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Size<T>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: FromLength> FromLength for Size<T>
impl<T: FromLength> FromLength for Size<T>
source§impl<T: FromPercent> FromPercent for Size<T>
impl<T: FromPercent> FromPercent for Size<T>
source§impl<In, Out, T: MaybeMath<In, Out>> MaybeMath<Size<In>, Size<Out>> for Size<T>
impl<In, Out, T: MaybeMath<In, Out>> MaybeMath<Size<In>, Size<Out>> for Size<T>
source§impl<In, Out, T: MaybeResolve<In, Out>> MaybeResolve<Size<In>, Size<Out>> for Size<T>
impl<In, Out, T: MaybeResolve<In, Out>> MaybeResolve<Size<In>, Size<Out>> for Size<T>
source§fn maybe_resolve(self, context: Size<In>) -> Size<Out>
fn maybe_resolve(self, context: Size<In>) -> Size<Out>
Converts any parent
-relative values for size into an absolute size
source§impl<In: Copy, Out: TaffyZero, T: ResolveOrZero<In, Out>> ResolveOrZero<Size<In>, Rect<Out>> for Rect<T>
impl<In: Copy, Out: TaffyZero, T: ResolveOrZero<In, Out>> ResolveOrZero<Size<In>, Rect<Out>> for Rect<T>
source§fn resolve_or_zero(self, context: Size<In>) -> Rect<Out>
fn resolve_or_zero(self, context: Size<In>) -> Rect<Out>
Converts any parent
-relative values for Rect into an absolute Rect
source§impl<In, Out: TaffyZero, T: ResolveOrZero<In, Out>> ResolveOrZero<Size<In>, Size<Out>> for Size<T>
impl<In, Out: TaffyZero, T: ResolveOrZero<In, Out>> ResolveOrZero<Size<In>, Size<Out>> for Size<T>
source§fn resolve_or_zero(self, context: Size<In>) -> Size<Out>
fn resolve_or_zero(self, context: Size<In>) -> Size<Out>
Converts any parent
-relative values for size into an absolute size
source§impl<T: TaffyFitContent> TaffyFitContent for Size<T>
impl<T: TaffyFitContent> TaffyFitContent for Size<T>
source§fn fit_content(argument: LengthPercentage) -> Self
fn fit_content(argument: LengthPercentage) -> Self
source§impl<T: TaffyMaxContent> TaffyMaxContent for Size<T>
impl<T: TaffyMaxContent> TaffyMaxContent for Size<T>
source§const MAX_CONTENT: Size<T> = _
const MAX_CONTENT: Size<T> = _
source§impl<T: TaffyMinContent> TaffyMinContent for Size<T>
impl<T: TaffyMinContent> TaffyMinContent for Size<T>
source§const MIN_CONTENT: Size<T> = _
const MIN_CONTENT: Size<T> = _
impl<T: Copy> Copy for Size<T>
impl<T: Eq> Eq for Size<T>
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> 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)