summaryrefslogtreecommitdiff
path: root/src/geom/length.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-02-17 12:14:50 +0100
committerLaurenz <laurmaedje@gmail.com>2022-02-17 12:14:50 +0100
commitc7a9bac99224af9673f26ec140af48e1728fe3b5 (patch)
treec7611385e8f0245b69e1e8cb24d36d2689808528 /src/geom/length.rs
parentab95627d873239182e7b28b266f8b9f9da5cdbb1 (diff)
Better debug implementations for numeric types
Diffstat (limited to 'src/geom/length.rs')
-rw-r--r--src/geom/length.rs20
1 files changed, 1 insertions, 19 deletions
diff --git a/src/geom/length.rs b/src/geom/length.rs
index b01a7123..a095b9ad 100644
--- a/src/geom/length.rs
+++ b/src/geom/length.rs
@@ -139,17 +139,7 @@ impl Length {
impl Debug for Length {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- use LengthUnit::*;
-
- // Format with the unit that yields the shortest output, preferring
- // larger / metric units when tied.
- let unit = [Cm, Mm, In, Pt]
- .iter()
- .copied()
- .min_by_key(|&unit| self.to_unit(unit).to_string().len())
- .unwrap();
-
- write!(f, "{}{:?}", self.to_unit(unit), unit)
+ write!(f, "{}pt", round_2(self.to_pt()))
}
}
@@ -264,12 +254,4 @@ mod tests {
fn test_length_unit_conversion() {
assert!((Length::mm(150.0).to_cm() - 15.0) < 1e-4);
}
-
- #[test]
- fn test_length_formatting() {
- assert_eq!(format!("{:?}", Length::pt(23.0)), "23pt");
- assert_eq!(format!("{:?}", Length::pt(-28.3465)), "-1cm");
- assert_eq!(format!("{:?}", Length::cm(12.728)), "12.728cm");
- assert_eq!(format!("{:?}", Length::cm(4.5)), "45mm");
- }
}