summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2023-01-05 17:19:31 +0100
committerLibravatar GitHub <noreply@github.com>2023-01-05 17:19:31 +0100
commit43374f1f4e865094032946907dbcf7569ee9487d (patch)
tree7b4cd12d344a9c32c7d6d1324d1e460486f0d265 /native
parentdca3d1fa7cef2c6e560b8165e3c474859a41e2ea (diff)
parent31abc4ce0d8be384872c26fd1209382af6231c6c (diff)
downloadiced-43374f1f4e865094032946907dbcf7569ee9487d.tar.gz
iced-43374f1f4e865094032946907dbcf7569ee9487d.tar.bz2
iced-43374f1f4e865094032946907dbcf7569ee9487d.zip
Merge pull request #1637 from iced-rs/fix/layout-resolve-panic
Fix `Layout::resolve` panicking under some circumstances
Diffstat (limited to 'native')
-rw-r--r--native/src/layout/limits.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/native/src/layout/limits.rs b/native/src/layout/limits.rs
index 33a452d0..0ddee91a 100644
--- a/native/src/layout/limits.rs
+++ b/native/src/layout/limits.rs
@@ -153,12 +153,17 @@ impl Limits {
/// Computes the resulting [`Size`] that fits the [`Limits`] given the
/// intrinsic size of some content.
+ #[allow(clippy::manual_clamp)]
pub fn resolve(&self, intrinsic_size: Size) -> Size {
Size::new(
- intrinsic_size.width.clamp(self.fill.width, self.max.width),
+ intrinsic_size
+ .width
+ .min(self.max.width)
+ .max(self.fill.width),
intrinsic_size
.height
- .clamp(self.fill.height, self.max.height),
+ .min(self.max.height)
+ .max(self.fill.height),
)
}
}