From 449b4cccd8bf75902f0367841eaf14ad0a953872 Mon Sep 17 00:00:00 2001 From: Janis Date: Sun, 8 May 2022 01:10:23 +0200 Subject: [PATCH] added clamp function to Size --- src/util.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util.rs b/src/util.rs index bfc5fc2..c052b1b 100644 --- a/src/util.rs +++ b/src/util.rs @@ -123,6 +123,13 @@ mod size { (self.width, self.height) } + pub fn clamp(self, other: Self) -> Self { + Self::new( + self.width.min(other.width), + self.height.min(other.height), + ) + } + pub fn map(self, f: F) -> Self where F: FnOnce(I, I) -> Self,