diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-03-14 20:28:28 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-03-14 20:52:32 +0100 |
| commit | 288a926feae1e73dff5a6b103aa920d6f7eb0f35 (patch) | |
| tree | 186be7eb8260c7a30938bf14c52bbf75e9b40bff /src/geom | |
| parent | 9c7067bce3a4e683411dacc8653976b055570b39 (diff) | |
Knuth-Plass and MicroType
Diffstat (limited to 'src/geom')
| -rw-r--r-- | src/geom/em.rs | 6 | ||||
| -rw-r--r-- | src/geom/relative.rs | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/geom/em.rs b/src/geom/em.rs index b9f1d897..d1cf3288 100644 --- a/src/geom/em.rs +++ b/src/geom/em.rs @@ -108,3 +108,9 @@ assign_impl!(Em += Em); assign_impl!(Em -= Em); assign_impl!(Em *= f64); assign_impl!(Em /= f64); + +impl Sum for Em { + fn sum<I: Iterator<Item = Self>>(iter: I) -> Self { + Self(iter.map(|s| s.0).sum()) + } +} diff --git a/src/geom/relative.rs b/src/geom/relative.rs index 4b638805..885de34a 100644 --- a/src/geom/relative.rs +++ b/src/geom/relative.rs @@ -43,6 +43,11 @@ impl Relative { self.0 == 0.0 } + /// Whether the ratio is one. + pub fn is_one(self) -> bool { + self.0 == 1.0 + } + /// The absolute value of the this relative. pub fn abs(self) -> Self { Self::new(self.get().abs()) |
