From 01fbd5049d09b44369b7cd1f283c473afda5d2be Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 27 Feb 2024 01:21:02 +0100 Subject: Fix `Column` and `Row` fluidity being overridden by `push` --- core/src/length.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'core/src/length.rs') diff --git a/core/src/length.rs b/core/src/length.rs index 4c139895..5f24169f 100644 --- a/core/src/length.rs +++ b/core/src/length.rs @@ -48,12 +48,21 @@ impl Length { /// Specifically: /// - [`Length::Shrink`] if [`Length::Shrink`] or [`Length::Fixed`]. /// - [`Length::Fill`] otherwise. - pub fn fluid(&self) -> Length { + pub fn fluid(&self) -> Self { match self { Length::Fill | Length::FillPortion(_) => Length::Fill, Length::Shrink | Length::Fixed(_) => Length::Shrink, } } + + /// Adapts the [`Length`] so it can contain the other [`Length`] and + /// match its fluidity. + pub fn enclose(self, other: Length) -> Self { + match (self, other) { + (Length::Shrink, Length::Fill | Length::FillPortion(_)) => other, + _ => self, + } + } } impl From for Length { -- cgit