diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs
index eb67fc144..aebbd75b4 100644
--- a/src/compute/flexbox.rs
+++ b/src/compute/flexbox.rs
@@ -574,7 +574,7 @@ fn determine_flex_base_size(
// Parent size for child sizing
let cross_axis_parent_size = constants.node_inner_size.cross(dir);
- let child_parent_size = Size::NONE.with_cross(dir, cross_axis_parent_size);
+ let child_parent_size = Size::from_cross(dir, cross_axis_parent_size);
// Available space for child sizing
let cross_axis_margin_sum = constants.margin.cross_axis_sum(dir);
diff --git a/src/geometry.rs b/src/geometry.rs
index 7d620adc0..497989ff0 100644
--- a/src/geometry.rs
+++ b/src/geometry.rs
@@ -559,6 +559,18 @@ impl Size<Option<f32>> {
Size { width: Some(width), height: Some(height) }
}
+ /// Creates a new [`Size<Option<f32>>`] with either the width or height set based on the provided `direction`
+ #[cfg(feature = "flexbox")]
+ pub fn from_cross(direction: FlexDirection, value: Option<f32>) -> Self {
+ let mut new = Self::NONE;
+ if direction.is_row() {
+ new.height = value
+ } else {
+ new.width = value
+ }
+ new
+ }
+
/// Applies aspect_ratio (if one is supplied) to the Size:
/// - If width is `Some` but height is `None`, then height is computed from width and aspect_ratio
/// - If height is `Some` but width is `None`, then width is computed from height and aspect_ratio