pub enum AvailableSpace {
Definite(f32),
MinContent,
MaxContent,
}Expand description
Available space for layout, similar to Taffy’s AvailableSpace.
This type explicitly represents the three possible states for available space:
Definite(f32): A specific pixel width is availableMinContent: Layout should use minimum content width (shrink-wrap)MaxContent: Layout should use maximum content width (no line breaks unless necessary)
This is critical for proper handling of intrinsic sizing in Flexbox/Grid where the available space may be indefinite during the measure phase.
Variants§
Definite(f32)
A specific amount of space is available (in pixels)
MinContent
The node should be laid out under a min-content constraint
MaxContent
The node should be laid out under a max-content constraint
Implementations§
Source§impl AvailableSpace
impl AvailableSpace
Sourcepub fn is_definite(&self) -> bool
pub fn is_definite(&self) -> bool
Returns true if this is a definite (finite, known) amount of space
Sourcepub fn is_indefinite(&self) -> bool
pub fn is_indefinite(&self) -> bool
Returns true if this is an indefinite (min-content or max-content) constraint
Sourcepub fn unwrap_or(self, fallback: f32) -> f32
pub fn unwrap_or(self, fallback: f32) -> f32
Returns the definite value if available, or a fallback for indefinite constraints
Sourcepub fn to_f32_for_layout(self) -> f32
pub fn to_f32_for_layout(self) -> f32
Returns the definite value, or 0.0 for min-content, or f32::MAX for max-content
Sourcepub fn from_f32(value: f32) -> Self
pub fn from_f32(value: f32) -> Self
Create from an f32 value, recognizing special sentinel values.
This function provides backwards compatibility with code that uses f32 for constraints:
f32::INFINITYorf32::MAX→MaxContent(no line wrapping)0.0→MinContent(maximum line wrapping, return longest word width)- Other values →
Definite(value)
Note: Using sentinel values like 0.0 for MinContent is fragile. Prefer using
AvailableSpace::MinContent directly when possible.
Trait Implementations§
Source§impl Clone for AvailableSpace
impl Clone for AvailableSpace
Source§fn clone(&self) -> AvailableSpace
fn clone(&self) -> AvailableSpace
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AvailableSpace
impl Debug for AvailableSpace
Source§impl Default for AvailableSpace
impl Default for AvailableSpace
Source§impl Hash for AvailableSpace
impl Hash for AvailableSpace
Source§impl PartialEq for AvailableSpace
impl PartialEq for AvailableSpace
impl Copy for AvailableSpace
impl StructuralPartialEq for AvailableSpace
Auto Trait Implementations§
impl Freeze for AvailableSpace
impl RefUnwindSafe for AvailableSpace
impl Send for AvailableSpace
impl Sync for AvailableSpace
impl Unpin for AvailableSpace
impl UnwindSafe for AvailableSpace
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§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