summaryrefslogtreecommitdiff
path: root/src/geom/length.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-05-17 22:55:31 +0200
committerLaurenz <laurmaedje@gmail.com>2021-05-17 22:55:31 +0200
commitc975d0d5e989cca6eff8e80ca8174f85eb4a3460 (patch)
tree7aaf68ee71d81a1d71d7dcb1f928659bc6fa975d /src/geom/length.rs
parent24c4a746bc68874f2d1b0d1b726596930acaadcf (diff)
Tidy up layouting code
Diffstat (limited to 'src/geom/length.rs')
-rw-r--r--src/geom/length.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/geom/length.rs b/src/geom/length.rs
index c75f79b5..8bc50e97 100644
--- a/src/geom/length.rs
+++ b/src/geom/length.rs
@@ -79,11 +79,21 @@ impl Length {
Self { raw: self.raw.min(other.raw) }
}
+ /// Set to the minimum of this and another length.
+ pub fn set_min(&mut self, other: Self) {
+ *self = self.min(other);
+ }
+
/// The maximum of this and another length.
pub fn max(self, other: Self) -> Self {
Self { raw: self.raw.max(other.raw) }
}
+ /// Set to the maximum of this and another length.
+ pub fn set_max(&mut self, other: Self) {
+ *self = self.max(other);
+ }
+
/// Whether the other length fits into this one (i.e. is smaller).
pub fn fits(self, other: Self) -> bool {
self.raw + 1e-6 >= other.raw