Merge pull request #1637 from iced-rs/fix/layout-resolve-panic

Fix `Layout::resolve` panicking under some circumstances
This commit is contained in:
Héctor Ramón 2023-01-05 17:19:31 +01:00 committed by GitHub
commit 43374f1f4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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),
)
}
}