summaryrefslogtreecommitdiff
path: root/src/size.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2019-11-20 17:28:58 +0100
committerLaurenz <laurmaedje@gmail.com>2019-11-20 17:31:52 +0100
commitf24e9b44e0ceb19be6f4e16af2d22815e9ccf5b7 (patch)
tree9e520ee1f8b802973aa5b568c11fafc42e6426a8 /src/size.rs
parent1dafe2c2ea0828bb075fdbb0da663967f7b5b2b9 (diff)
Refined expansion model 🔛
Diffstat (limited to 'src/size.rs')
-rw-r--r--src/size.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/size.rs b/src/size.rs
index 5c87ad37..fac31625 100644
--- a/src/size.rs
+++ b/src/size.rs
@@ -95,6 +95,12 @@ impl Size {
pub fn to_inches(&self) -> f32 {
self.points * 0.0138889
}
+
+ /// Set this size to the maximum of itself and the other size.
+ #[inline]
+ pub fn max_eq(&mut self, other: Size) {
+ *self = max(*self, other);
+ }
}
impl Size2D {
@@ -146,6 +152,14 @@ impl Size2D {
pub fn fits(&self, other: Size2D) -> bool {
self.x >= other.x && self.y >= other.y
}
+
+ /// Set this size to the maximum of itself and the other size
+ /// (for both dimensions).
+ #[inline]
+ pub fn max_eq(&mut self, other: Size2D) {
+ self.x.max_eq(other.x);
+ self.y.max_eq(other.y);
+ }
}
impl SizeBox {