From b7ea43f5196cbdf14d89d1f0bc0c219fa0704cff Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 30 Sep 2024 16:44:42 +0200 Subject: [PATCH] Add `Rect::round` --- crates/emath/src/rect.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/emath/src/rect.rs b/crates/emath/src/rect.rs index 6c0677ad5..0fb4ac91d 100644 --- a/crates/emath/src/rect.rs +++ b/crates/emath/src/rect.rs @@ -245,6 +245,16 @@ impl Rect { ) } + /// Round to integer + #[must_use] + #[inline] + pub fn round(self) -> Self { + Self { + min: self.min.round(), + max: self.max.round(), + } + } + #[must_use] #[inline] pub fn intersects(self, other: Self) -> bool {