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§
§impl<T> Size<T>
impl<T> Size<T>
pub 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
§impl<T> Size<T>
impl<T> Size<T>
§impl Size<f32>
impl Size<f32>
pub 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
§impl Size<Option<f32>>
impl Size<Option<f32>>
pub 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
pub fn from_cross(
direction: FlexDirection,
value: Option<f32>,
) -> Size<Option<f32>>
pub fn from_cross( direction: FlexDirection, value: Option<f32>, ) -> Size<Option<f32>>
Creates a new Size<Option<f32>>
with either the width or height set based on the provided direction
pub 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.
§impl Size<Dimension>
impl Size<Dimension>
pub const fn from_lengths(width: f32, height: f32) -> Size<Dimension>
pub const fn from_lengths(width: f32, height: f32) -> Size<Dimension>
Generates a Size<Dimension>
using Dimension::Length
values
pub 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
§impl Size<AvailableSpace>
impl Size<AvailableSpace>
pub fn into_options(self) -> Size<Option<f32>>
pub fn into_options(self) -> Size<Option<f32>>
Convert Size<AvailableSpace>
into Size<Option<f32>>
§impl<T> Size<T>where
T: TaffyMinContent,
impl<T> Size<T>where
T: TaffyMinContent,
pub 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)
§impl<T> Size<T>where
T: TaffyMaxContent,
impl<T> Size<T>where
T: TaffyMaxContent,
pub 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)
§impl<T> Size<T>where
T: TaffyFitContent,
impl<T> Size<T>where
T: TaffyFitContent,
pub fn fit_content(argument: LengthPercentage) -> Size<T>
pub fn fit_content(argument: LengthPercentage) -> Size<T>
Returns a Size where with width and height set to the same fit-content(…)
value
with the given argument.
§impl<T> Size<T>where
T: FromLength,
impl<T> Size<T>where
T: FromLength,
Trait Implementations§
§impl<'de, T> Deserialize<'de> for Size<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Size<T>where
T: Deserialize<'de>,
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Size<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Size<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl<T> FromLength for Size<T>where
T: FromLength,
impl<T> FromLength for Size<T>where
T: FromLength,
§impl<T> FromPercent for Size<T>where
T: FromPercent,
impl<T> FromPercent for Size<T>where
T: FromPercent,
§impl<In, Out, T> MaybeMath<Size<In>, Size<Out>> for Size<T>where
T: MaybeMath<In, Out>,
impl<In, Out, T> MaybeMath<Size<In>, Size<Out>> for Size<T>where
T: MaybeMath<In, Out>,
§fn maybe_clamp(self, min: Size<In>, max: Size<In>) -> Size<Out>
fn maybe_clamp(self, min: Size<In>, max: Size<In>) -> Size<Out>
self
clamped between min
and max
§impl<In, Out, T> MaybeResolve<Size<In>, Size<Out>> for Size<T>where
T: MaybeResolve<In, Out>,
impl<In, Out, T> MaybeResolve<Size<In>, Size<Out>> for Size<T>where
T: MaybeResolve<In, Out>,
§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
§impl<In, Out, T> ResolveOrZero<Size<In>, Rect<Out>> for Rect<T>
impl<In, Out, T> ResolveOrZero<Size<In>, Rect<Out>> for Rect<T>
§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
§impl<In, Out, T> ResolveOrZero<Size<In>, Size<Out>> for Size<T>where
Out: TaffyZero,
T: ResolveOrZero<In, Out>,
impl<In, Out, T> ResolveOrZero<Size<In>, Size<Out>> for Size<T>where
Out: TaffyZero,
T: ResolveOrZero<In, Out>,
§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
§impl<T> Serialize for Size<T>where
T: Serialize,
impl<T> Serialize for Size<T>where
T: Serialize,
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl<T> TaffyFitContent for Size<T>where
T: TaffyFitContent,
impl<T> TaffyFitContent for Size<T>where
T: TaffyFitContent,
§fn fit_content(argument: LengthPercentage) -> Size<T>
fn fit_content(argument: LengthPercentage) -> Size<T>
§impl<T> TaffyMaxContent for Size<T>where
T: TaffyMaxContent,
impl<T> TaffyMaxContent for Size<T>where
T: TaffyMaxContent,
§const MAX_CONTENT: Size<T> = _
const MAX_CONTENT: Size<T> = _
§impl<T> TaffyMinContent for Size<T>where
T: TaffyMinContent,
impl<T> TaffyMinContent for Size<T>where
T: TaffyMinContent,
§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> 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
)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> 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