diff options
author | 2022-12-20 11:31:25 +0100 | |
---|---|---|
committer | 2022-12-20 11:31:25 +0100 | |
commit | 6bb01b727611b83592f96b2b89371a12e7ce54d8 (patch) | |
tree | c75ba7d21b0bec1f5000b6e4ababff923d09387c /native/src/layout | |
parent | e0c728c62c6fd9496de1d442e7476e24fc5e9023 (diff) | |
download | iced-6bb01b727611b83592f96b2b89371a12e7ce54d8.tar.gz iced-6bb01b727611b83592f96b2b89371a12e7ce54d8.tar.bz2 iced-6bb01b727611b83592f96b2b89371a12e7ce54d8.zip |
Fix `clippy` lints for Rust 1.66
Diffstat (limited to 'native/src/layout')
-rw-r--r-- | native/src/layout/limits.rs | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/native/src/layout/limits.rs b/native/src/layout/limits.rs index 6d5f6563..33a452d0 100644 --- a/native/src/layout/limits.rs +++ b/native/src/layout/limits.rs @@ -51,7 +51,7 @@ impl Limits { } Length::Units(units) => { let new_width = - (units as f32).min(self.max.width).max(self.min.width); + (units as f32).clamp(self.min.width, self.max.width); self.min.width = new_width; self.max.width = new_width; @@ -73,7 +73,7 @@ impl Limits { } Length::Units(units) => { let new_height = - (units as f32).min(self.max.height).max(self.min.height); + (units as f32).clamp(self.min.height, self.max.height); self.min.height = new_height; self.max.height = new_height; @@ -86,16 +86,14 @@ impl Limits { /// Applies a minimum width constraint to the current [`Limits`]. pub fn min_width(mut self, min_width: u32) -> Limits { - self.min.width = - self.min.width.max(min_width as f32).min(self.max.width); + self.min.width = self.min.width.clamp(min_width as f32, self.max.width); self } /// Applies a maximum width constraint to the current [`Limits`]. pub fn max_width(mut self, max_width: u32) -> Limits { - self.max.width = - self.max.width.min(max_width as f32).max(self.min.width); + self.max.width = self.max.width.clamp(self.min.width, max_width as f32); self } @@ -103,7 +101,7 @@ impl Limits { /// Applies a minimum height constraint to the current [`Limits`]. pub fn min_height(mut self, min_height: u32) -> Limits { self.min.height = - self.min.height.max(min_height as f32).min(self.max.height); + self.min.height.clamp(min_height as f32, self.max.height); self } @@ -111,7 +109,7 @@ impl Limits { /// Applies a maximum height constraint to the current [`Limits`]. pub fn max_height(mut self, max_height: u32) -> Limits { self.max.height = - self.max.height.min(max_height as f32).max(self.min.height); + self.max.height.clamp(self.min.height, max_height as f32); self } @@ -157,14 +155,10 @@ impl Limits { /// intrinsic size of some content. pub fn resolve(&self, intrinsic_size: Size) -> Size { Size::new( - intrinsic_size - .width - .min(self.max.width) - .max(self.fill.width), + intrinsic_size.width.clamp(self.fill.width, self.max.width), intrinsic_size .height - .min(self.max.height) - .max(self.fill.height), + .clamp(self.fill.height, self.max.height), ) } } |