summaryrefslogtreecommitdiff
path: root/src/geom/length.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-06-15 16:34:41 +0200
committerLaurenz <laurmaedje@gmail.com>2021-06-15 16:34:41 +0200
commite2cdda67dc0e16b9a482aa3a4bfd5991db06d143 (patch)
tree7a3ee517b7417c08888eac105ca1431b9d3817cf /src/geom/length.rs
parenta61ee46ed2d39d7b7b0c14e6c36d224e03532bac (diff)
Refactor grid row layout
Diffstat (limited to 'src/geom/length.rs')
-rw-r--r--src/geom/length.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/geom/length.rs b/src/geom/length.rs
index 21843d3e..ecfe5616 100644
--- a/src/geom/length.rs
+++ b/src/geom/length.rs
@@ -18,6 +18,11 @@ impl Length {
Self { raw: N64::from(0.0) }
}
+ /// The inifinite length.
+ pub fn inf() -> Self {
+ Self { raw: N64::from(f64::INFINITY) }
+ }
+
/// Create a length from a number of points.
pub fn pt(pt: f64) -> Self {
Self::with_unit(pt, LengthUnit::Pt)
@@ -203,6 +208,12 @@ impl Sum for Length {
}
}
+impl<'a> Sum<&'a Length> for Length {
+ fn sum<I: Iterator<Item = &'a Length>>(iter: I) -> Self {
+ iter.copied().fold(Length::zero(), Add::add)
+ }
+}
+
/// Different units of length measurement.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub enum LengthUnit {