From ee84bf74083f5b9cc88a2a0a968dc905b1eef22c Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 30 Aug 2021 16:59:09 +0200 Subject: Add abs() function --- src/geom/length.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/geom/length.rs') diff --git a/src/geom/length.rs b/src/geom/length.rs index f8484f75..b9eb7b75 100644 --- a/src/geom/length.rs +++ b/src/geom/length.rs @@ -92,6 +92,11 @@ impl Length { self.0.into_inner().is_infinite() } + /// The absolute value of the this length. + pub fn abs(self) -> Self { + Self::raw(self.to_raw().abs()) + } + /// The minimum of this and another length. pub fn min(self, other: Self) -> Self { Self(self.0.min(other.0)) -- cgit v1.2.3