added clamp function to Size<T>

This commit is contained in:
Janis 2022-05-08 01:10:23 +02:00 committed by Gitea
parent 6c4f0d54bd
commit 449b4cccd8

View file

@ -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<F>(self, f: F) -> Self
where
F: FnOnce(I, I) -> Self,