pub enum Length {
Auto,
Cells(u16),
Percent(u16),
Min(u16),
Max(u16),
Var {
name: String,
fallback: Option<Box<Length>>,
},
}Expand description
A one-dimensional size, mapped to a ratatui Constraint.
Not Copy: the Length::Var variant carries a heap-allocated name, so a
Length must be .clone()-d when duplicated (which is rare outside the
cascade, where var() references have already been resolved away).
Variants§
Auto
auto — let the layout engine decide (becomes Min(0)).
Cells(u16)
A fixed cell count (10, 10px).
Percent(u16)
A percentage of the available space (50%).
Min(u16)
min(n) — at least n cells, grow if room.
Max(u16)
max(n) — at most n cells.
Var
A var(--name) reference, resolved against the token table during the
cascade. A Length::Var should never survive into to_constraint — if
one does (e.g. an unresolved variable in lenient mode), it degrades to
Min(0) (same as Length::Auto) rather than panicking.
Fallback (var(--x, 10)) is not yet supported: if a fallback is present
it is currently ignored and only the name is captured.
Implementations§
Source§impl Length
impl Length
pub fn parse(s: &str) -> Result<Self>
pub fn to_constraint(&self) -> Constraint
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Length
impl<'de> Deserialize<'de> for Length
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
impl StructuralPartialEq for Length
Auto Trait Implementations§
impl Freeze for Length
impl RefUnwindSafe for Length
impl Send for Length
impl Sync for Length
impl Unpin for Length
impl UnsafeUnpin for Length
impl UnwindSafe for Length
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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