summaryrefslogtreecommitdiff
path: root/src/geom/length.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-12-20 16:08:16 +0100
committerLaurenz <laurmaedje@gmail.com>2022-12-20 16:11:37 +0100
commitf5f7df7247ae29800e0290774a50942e2485beea (patch)
tree57253ba51efdae3ac8e4eea722428924625b514c /src/geom/length.rs
parentb8ffd3ad3dcaebddbc674e03494e0d818b21fa51 (diff)
Documentation
Diffstat (limited to 'src/geom/length.rs')
-rw-r--r--src/geom/length.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/geom/length.rs b/src/geom/length.rs
index 230ea48b..ae615f14 100644
--- a/src/geom/length.rs
+++ b/src/geom/length.rs
@@ -18,6 +18,12 @@ impl Length {
Self { abs: Abs::zero(), em: Em::zero() }
}
+ /// Try to compute the absolute value of the length.
+ pub fn try_abs(self) -> Option<Self> {
+ (self.abs.is_zero() || self.em.is_zero())
+ .then(|| Self { abs: self.abs.abs(), em: self.em.abs() })
+ }
+
/// Try to divide two lengths.
pub fn try_div(self, other: Self) -> Option<f64> {
if self.abs.is_zero() && other.abs.is_zero() {