Merge pull request #1637 from iced-rs/fix/layout-resolve-panic
Fix `Layout::resolve` panicking under some circumstances
This commit is contained in:
commit
43374f1f4e
1 changed files with 7 additions and 2 deletions
|
|
@ -153,12 +153,17 @@ impl Limits {
|
||||||
|
|
||||||
/// Computes the resulting [`Size`] that fits the [`Limits`] given the
|
/// Computes the resulting [`Size`] that fits the [`Limits`] given the
|
||||||
/// intrinsic size of some content.
|
/// intrinsic size of some content.
|
||||||
|
#[allow(clippy::manual_clamp)]
|
||||||
pub fn resolve(&self, intrinsic_size: Size) -> Size {
|
pub fn resolve(&self, intrinsic_size: Size) -> Size {
|
||||||
Size::new(
|
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
|
intrinsic_size
|
||||||
.height
|
.height
|
||||||
.clamp(self.fill.height, self.max.height),
|
.min(self.max.height)
|
||||||
|
.max(self.fill.height),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue