pub enum Constraint {
Length(u16),
Percentage(u16),
Ratio(u16, u16),
Min(u16),
Max(u16),
Fill,
Fit,
}Expand description
Sizing constraint for a layout child along the parent’s primary
axis. Resolved by resolve_constraints against the parent’s total
size, in declaration order:
- Hard sizes first (
Length,Percentage,Ratio,Max) andFit(resolved against the leaf’s natural size via the activeLeafSizer) consume their exact share of the available space. Min(n)reserves at leastncells, then competes withFillfor the remainder.Fill(and any unsatisfiedMin) splits whatever remains evenly.
Fit reports the leaf’s natural size from LeafSizer; with the
default NoopSizer it contributes 0 (i.e. behaves like Fill).
Variants§
Length(u16)
Exactly n cells along the axis.
Percentage(u16)
p percent of the parent’s total size, clamped to remaining.
Ratio(u16, u16)
Proportional share num / denom of the parent. Multiple
Ratio siblings split proportionally to one another.
Min(u16)
At least n cells; competes with Fill for the remainder
once the minimum is satisfied.
Max(u16)
At most n cells. Acts like Length(n) when the parent has
at least n available; smaller parents shrink it.
Fill
Fill the remaining space; siblings split evenly.
Fit
Size to the leaf’s natural content. Falls back to Fill
until leaves expose a natural-size hook.
Trait Implementations§
Source§impl Clone for Constraint
impl Clone for Constraint
Source§fn clone(&self) -> Constraint
fn clone(&self) -> Constraint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Constraint
Source§impl Debug for Constraint
impl Debug for Constraint
impl Eq for Constraint
Source§impl PartialEq for Constraint
impl PartialEq for Constraint
Source§fn eq(&self, other: &Constraint) -> bool
fn eq(&self, other: &Constraint) -> bool
self and other values to be equal, and is used by ==.