diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-10-31 13:51:28 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-10-31 13:51:28 +0100 |
| commit | 564cb7e989fcbc6ef3d55a17f9b38faba9f80c4f (patch) | |
| tree | c5e44b8e88f0fd082e7d231a521b7375c2b9703a /src/geom | |
| parent | 4645d1a517560fc2efbdb4791df176b670eef8f4 (diff) | |
Fix panic in pad node
Diffstat (limited to 'src/geom')
| -rw-r--r-- | src/geom/length.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/geom/length.rs b/src/geom/length.rs index d0f11bd2..de184e6c 100644 --- a/src/geom/length.rs +++ b/src/geom/length.rs @@ -126,6 +126,13 @@ impl Length { pub fn approx_eq(self, other: Self) -> bool { self == other || (self - other).to_raw().abs() < 1e-6 } + + /// Perform a checked division by a number, returning `None` if the result + /// is not finite. + pub fn div_finite(self, number: f64) -> Option<Self> { + let result = self.to_raw() / number; + result.is_finite().then(|| Self::raw(result)) + } } impl Debug for Length { |
