diff options
Diffstat (limited to 'src/geom')
| -rw-r--r-- | src/geom/align.rs | 4 | ||||
| -rw-r--r-- | src/geom/angle.rs | 13 | ||||
| -rw-r--r-- | src/geom/dir.rs | 4 | ||||
| -rw-r--r-- | src/geom/em.rs | 6 | ||||
| -rw-r--r-- | src/geom/fr.rs | 6 | ||||
| -rw-r--r-- | src/geom/gen.rs | 9 | ||||
| -rw-r--r-- | src/geom/length.rs | 21 | ||||
| -rw-r--r-- | src/geom/linear.rs | 6 | ||||
| -rw-r--r-- | src/geom/mod.rs | 2 | ||||
| -rw-r--r-- | src/geom/relative.rs | 6 | ||||
| -rw-r--r-- | src/geom/spec.rs | 9 |
11 files changed, 15 insertions, 71 deletions
diff --git a/src/geom/align.rs b/src/geom/align.rs index d83c00b0..59960084 100644 --- a/src/geom/align.rs +++ b/src/geom/align.rs @@ -1,7 +1,7 @@ use super::*; /// Where to align something along an axis. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] pub enum Align { /// Align at the start of the axis. Start, @@ -81,7 +81,7 @@ impl Default for Align { } } -impl Display for Align { +impl Debug for Align { fn fmt(&self, f: &mut Formatter) -> fmt::Result { f.pad(match self { Self::Start => "start", diff --git a/src/geom/angle.rs b/src/geom/angle.rs index b6fa3f41..929a96fe 100644 --- a/src/geom/angle.rs +++ b/src/geom/angle.rs @@ -59,13 +59,6 @@ impl Angle { impl Debug for Angle { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - let unit = AngularUnit::Deg; - write!(f, "{}{}", self.to_unit(unit), unit) - } -} - -impl Display for Angle { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { // Format with the unit that yields the shortest output, preferring // degrees when tied. let unit = [AngularUnit::Deg, AngularUnit::Rad] @@ -74,7 +67,7 @@ impl Display for Angle { .min_by_key(|&unit| self.to_unit(unit).to_string().len()) .unwrap(); - write!(f, "{}{}", self.to_unit(unit), unit) + write!(f, "{}{:?}", self.to_unit(unit), unit) } } @@ -139,7 +132,7 @@ impl Sum for Angle { } } /// Different units of angular measurement. -#[derive(Debug, Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Eq, PartialEq)] pub enum AngularUnit { /// Radians. Rad, @@ -157,7 +150,7 @@ impl AngularUnit { } } -impl Display for AngularUnit { +impl Debug for AngularUnit { fn fmt(&self, f: &mut Formatter) -> fmt::Result { f.pad(match self { Self::Rad => "rad", diff --git a/src/geom/dir.rs b/src/geom/dir.rs index 7b224b55..d95c7eb9 100644 --- a/src/geom/dir.rs +++ b/src/geom/dir.rs @@ -1,7 +1,7 @@ use super::*; /// The four directions into which content can be laid out. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Copy, Clone, Eq, PartialEq, Hash)] pub enum Dir { /// Left to right. LTR, @@ -71,7 +71,7 @@ impl Dir { } } -impl Display for Dir { +impl Debug for Dir { fn fmt(&self, f: &mut Formatter) -> fmt::Result { f.pad(match self { Self::LTR => "ltr", diff --git a/src/geom/em.rs b/src/geom/em.rs index 45e5ba60..6d2f3aca 100644 --- a/src/geom/em.rs +++ b/src/geom/em.rs @@ -46,12 +46,6 @@ impl Em { impl Debug for Em { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - Display::fmt(self, f) - } -} - -impl Display for Em { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "{}em", self.get()) } } diff --git a/src/geom/fr.rs b/src/geom/fr.rs index 5f3e5534..c16a4d03 100644 --- a/src/geom/fr.rs +++ b/src/geom/fr.rs @@ -38,12 +38,6 @@ impl Fractional { impl Debug for Fractional { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - Display::fmt(self, f) - } -} - -impl Display for Fractional { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "{}fr", self.get()) } } diff --git a/src/geom/gen.rs b/src/geom/gen.rs index 1b42968a..18801460 100644 --- a/src/geom/gen.rs +++ b/src/geom/gen.rs @@ -115,12 +115,3 @@ impl GenAxis { } } } - -impl Display for GenAxis { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - f.pad(match self { - Self::Inline => "inline", - Self::Block => "block", - }) - } -} diff --git a/src/geom/length.rs b/src/geom/length.rs index b9eb7b75..d0f11bd2 100644 --- a/src/geom/length.rs +++ b/src/geom/length.rs @@ -130,13 +130,6 @@ impl Length { impl Debug for Length { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - let unit = LengthUnit::Pt; - write!(f, "{}{}", self.to_unit(unit), unit) - } -} - -impl Display for Length { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { use LengthUnit::*; // Format with the unit that yields the shortest output, preferring @@ -147,7 +140,7 @@ impl Display for Length { .min_by_key(|&unit| self.to_unit(unit).to_string().len()) .unwrap(); - write!(f, "{}{}", self.to_unit(unit), unit) + write!(f, "{}{:?}", self.to_unit(unit), unit) } } @@ -219,7 +212,7 @@ impl<'a> Sum<&'a Length> for Length { } /// Different units of length measurement. -#[derive(Debug, Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Eq, PartialEq)] pub enum LengthUnit { /// Points. Pt, @@ -243,7 +236,7 @@ impl LengthUnit { } } -impl Display for LengthUnit { +impl Debug for LengthUnit { fn fmt(&self, f: &mut Formatter) -> fmt::Result { f.pad(match self { LengthUnit::Mm => "mm", @@ -265,9 +258,9 @@ mod tests { #[test] fn test_length_formatting() { - assert_eq!(Length::pt(23.0).to_string(), "23pt"); - assert_eq!(Length::pt(-28.3465).to_string(), "-1cm"); - assert_eq!(Length::cm(12.728).to_string(), "12.728cm"); - assert_eq!(Length::cm(4.5).to_string(), "45mm"); + 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"); } } diff --git a/src/geom/linear.rs b/src/geom/linear.rs index 6a20b826..494007b0 100644 --- a/src/geom/linear.rs +++ b/src/geom/linear.rs @@ -53,12 +53,6 @@ impl Debug for Linear { } } -impl Display for Linear { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - write!(f, "{} + {}", self.rel, self.abs) - } -} - impl From<Length> for Linear { fn from(abs: Length) -> Self { Self { rel: Relative::zero(), abs } diff --git a/src/geom/mod.rs b/src/geom/mod.rs index 11e082b8..936f1868 100644 --- a/src/geom/mod.rs +++ b/src/geom/mod.rs @@ -33,7 +33,7 @@ pub use size::*; pub use spec::*; use std::f64::consts::PI; -use std::fmt::{self, Debug, Display, Formatter}; +use std::fmt::{self, Debug, Formatter}; use std::iter::Sum; use std::ops::*; diff --git a/src/geom/relative.rs b/src/geom/relative.rs index 9122af84..c2d0a0cb 100644 --- a/src/geom/relative.rs +++ b/src/geom/relative.rs @@ -51,12 +51,6 @@ impl Relative { impl Debug for Relative { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - Display::fmt(self, f) - } -} - -impl Display for Relative { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "{}%", 100.0 * self.get()) } } diff --git a/src/geom/spec.rs b/src/geom/spec.rs index 3b8b4dd6..a6235548 100644 --- a/src/geom/spec.rs +++ b/src/geom/spec.rs @@ -128,12 +128,3 @@ impl SpecAxis { } } } - -impl Display for SpecAxis { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - f.pad(match self { - Self::Horizontal => "horizontal", - Self::Vertical => "vertical", - }) - } -} |
