summaryrefslogtreecommitdiff
path: root/src/geom
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-06-27 19:02:23 +0200
committerGitHub <noreply@github.com>2021-06-27 19:02:23 +0200
commitd8d60207ef1833001196feccb84cc0c78bdd84df (patch)
treecdc2130d8b4265c52863f10418842d188afb63e8 /src/geom
parentf64c772b6d969fa3aa1a7391a3d8118b21430434 (diff)
parente9960b89424ab67e633076ccc9f8c420316b076a (diff)
Merge pull request #33 from typst/cache-patterns
A test framework for incremental compilation
Diffstat (limited to 'src/geom')
-rw-r--r--src/geom/length.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/geom/length.rs b/src/geom/length.rs
index ecfe5616..951cef4f 100644
--- a/src/geom/length.rs
+++ b/src/geom/length.rs
@@ -108,6 +108,11 @@ impl Length {
self.raw + 1e-6 >= other.raw
}
+ /// 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
+ }
+
/// Whether the length is zero.
pub fn is_zero(self) -> bool {
self.raw == 0.0