From 6b6cdae7ce95681d6a1194be70b375494166a8c6 Mon Sep 17 00:00:00 2001 From: Martin Haug Date: Sun, 27 Jun 2021 12:28:40 +0200 Subject: Testing for incremental Also, constraint bugfixes. --- src/geom/length.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/geom') diff --git a/src/geom/length.rs b/src/geom/length.rs index ecfe5616..08bf3111 100644 --- a/src/geom/length.rs +++ b/src/geom/length.rs @@ -108,6 +108,11 @@ impl Length { self.raw + 1e-6 >= other.raw } + /// Compares to lengths for whether they are approximately equal. + pub fn approx_eq(self, other: Self) -> bool { + self == other || (self - other).to_raw().abs() < 1e-6 + } + /// Whether the length is zero. pub fn is_zero(self) -> bool { self.raw == 0.0 -- cgit v1.2.3 From 57bd3e23c79878d106ab8be17c71caca6c4f5a7c Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 27 Jun 2021 17:08:40 +0200 Subject: Apply suggestions from code review Co-authored-by: Laurenz --- src/geom/length.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/geom') diff --git a/src/geom/length.rs b/src/geom/length.rs index 08bf3111..951cef4f 100644 --- a/src/geom/length.rs +++ b/src/geom/length.rs @@ -108,7 +108,7 @@ impl Length { self.raw + 1e-6 >= other.raw } - /// Compares to lengths for whether they are approximately equal. + /// Compares two lengths for whether they are approximately equal. pub fn approx_eq(self, other: Self) -> bool { self == other || (self - other).to_raw().abs() < 1e-6 } -- cgit v1.2.3