pub enum Size {
Fixed(f32),
Fill(f32),
Hug,
Aspect(f32),
}Expand description
Sizing intent along one axis.
-
Fixed(px)– exact size. -
Fill(weight)– claim a share of leftover space; weights are relative. -
Hug– intrinsic size of contents. -
Aspect(ratio)– size derived from the other axis:this = ratio * other. Use it to lock an El’s aspect ratio against a sibling-driven axis, e.g.width(Size::Fill(1.0)).height(Size::Aspect(nat_h / nat_w))for an image that fills its column’s width and reports a proportional height back so surrounding layout flows around it.Resolves on either axis. Inside a flex container, an
Aspecton the main axis triggers a cross-first ordering for that child only (cross resolves from its own intent, then main = cross × ratio). The opposite pairing (Aspecton cross with anything else on main) uses the normal main-then- cross flow. Both axesAspectis degenerate and falls back to intrinsic.min_width/max_width/min_height/max_heightapply to both axes: the basis is clamped before being multiplied byratio, and the derived axis is then clamped by its own bounds. A hugging parent will see the clamped intrinsic, so layout stays consistent with paint.
Variants§
Trait Implementations§
impl Copy for Size
impl StructuralPartialEq for Size
Auto Trait Implementations§
impl Freeze for Size
impl RefUnwindSafe for Size
impl Send for Size
impl Sync for Size
impl Unpin for Size
impl UnsafeUnpin for Size
impl UnwindSafe for Size
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.