diff options
Diffstat (limited to 'core/src/length.rs')
-rw-r--r-- | core/src/length.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/src/length.rs b/core/src/length.rs index 3adb996e..4c139895 100644 --- a/core/src/length.rs +++ b/core/src/length.rs @@ -36,6 +36,24 @@ impl Length { Length::Fixed(_) => 0, } } + + /// Returns `true` iff the [`Length`] is either [`Length::Fill`] or + // [`Length::FillPortion`]. + pub fn is_fill(&self) -> bool { + self.fill_factor() != 0 + } + + /// Returns the "fluid" variant of the [`Length`]. + /// + /// Specifically: + /// - [`Length::Shrink`] if [`Length::Shrink`] or [`Length::Fixed`]. + /// - [`Length::Fill`] otherwise. + pub fn fluid(&self) -> Length { + match self { + Length::Fill | Length::FillPortion(_) => Length::Fill, + Length::Shrink | Length::Fixed(_) => Length::Shrink, + } + } } impl From<Pixels> for Length { |