summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-03-19 21:23:03 +0100
committerLaurenz <laurmaedje@gmail.com>2021-03-19 21:23:03 +0100
commit898dc38ec153709929d2513fb9d040dd2c1ce0fe (patch)
tree11742165476f2c2595df91841808de3567b7c876 /src
parent264a7dedd42e27cd9e604037640cf0594b2ec46b (diff)
Better debug representations 💻
Diffstat (limited to 'src')
-rw-r--r--src/geom/angle.rs3
-rw-r--r--src/geom/gen.rs8
-rw-r--r--src/geom/length.rs3
-rw-r--r--src/geom/linear.rs2
-rw-r--r--src/geom/point.rs2
-rw-r--r--src/geom/size.rs2
-rw-r--r--src/geom/spec.rs8
-rw-r--r--src/layout/shaping.rs2
8 files changed, 22 insertions, 8 deletions
diff --git a/src/geom/angle.rs b/src/geom/angle.rs
index a0e2877a..938141ee 100644
--- a/src/geom/angle.rs
+++ b/src/geom/angle.rs
@@ -68,7 +68,8 @@ impl Display for Angle {
impl Debug for Angle {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- Display::fmt(self, f)
+ let unit = AngularUnit::Deg;
+ write!(f, "{:?}{:?}", self.to_unit(unit), unit)
}
}
diff --git a/src/geom/gen.rs b/src/geom/gen.rs
index 8723ea99..c80cc21b 100644
--- a/src/geom/gen.rs
+++ b/src/geom/gen.rs
@@ -1,7 +1,7 @@
use super::*;
/// A container with a main and cross component.
-#[derive(Debug, Default, Copy, Clone, Eq, PartialEq)]
+#[derive(Default, Copy, Clone, Eq, PartialEq)]
pub struct Gen<T> {
/// The main component.
pub main: T,
@@ -58,6 +58,12 @@ impl<T> Switch for Gen<T> {
}
}
+impl<T: Debug> Debug for Gen<T> {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ write!(f, "Gen({:?}, {:?})", self.main, self.cross)
+ }
+}
+
/// The two generic layouting axes.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum GenAxis {
diff --git a/src/geom/length.rs b/src/geom/length.rs
index bc836810..419da5c3 100644
--- a/src/geom/length.rs
+++ b/src/geom/length.rs
@@ -120,7 +120,8 @@ impl Display for Length {
impl Debug for Length {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- Display::fmt(self, f)
+ let unit = LengthUnit::Pt;
+ write!(f, "{}{}", self.to_unit(unit), unit)
}
}
diff --git a/src/geom/linear.rs b/src/geom/linear.rs
index 05990096..54ff71e6 100644
--- a/src/geom/linear.rs
+++ b/src/geom/linear.rs
@@ -40,7 +40,7 @@ impl Display for Linear {
impl Debug for Linear {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- Display::fmt(self, f)
+ write!(f, "{:?} + {:?}", self.rel, self.abs)
}
}
diff --git a/src/geom/point.rs b/src/geom/point.rs
index 0faa781c..cf8bc1a9 100644
--- a/src/geom/point.rs
+++ b/src/geom/point.rs
@@ -55,7 +55,7 @@ impl Switch for Point {
impl Debug for Point {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- write!(f, "({}, {})", self.x, self.y)
+ write!(f, "Point({:?}, {:?})", self.x, self.y)
}
}
diff --git a/src/geom/size.rs b/src/geom/size.rs
index caba3d8b..67e5643d 100644
--- a/src/geom/size.rs
+++ b/src/geom/size.rs
@@ -78,7 +78,7 @@ impl Switch for Size {
impl Debug for Size {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- write!(f, "({} x {})", self.width, self.height)
+ write!(f, "Size({:?}, {:?})", self.width, self.height)
}
}
diff --git a/src/geom/spec.rs b/src/geom/spec.rs
index c61f9526..510bac84 100644
--- a/src/geom/spec.rs
+++ b/src/geom/spec.rs
@@ -1,7 +1,7 @@
use super::*;
/// A container with a horizontal and vertical component.
-#[derive(Debug, Default, Copy, Clone, Eq, PartialEq)]
+#[derive(Default, Copy, Clone, Eq, PartialEq)]
pub struct Spec<T> {
/// The horizontal component.
pub horizontal: T,
@@ -74,6 +74,12 @@ impl<T> Switch for Spec<T> {
}
}
+impl<T: Debug> Debug for Spec<T> {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ write!(f, "Spec({:?}, {:?})", self.horizontal, self.vertical)
+ }
+}
+
/// The two specific layouting axes.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum SpecAxis {
diff --git a/src/layout/shaping.rs b/src/layout/shaping.rs
index 141fa10e..1b769db7 100644
--- a/src/layout/shaping.rs
+++ b/src/layout/shaping.rs
@@ -54,7 +54,7 @@ impl Shaped {
impl Debug for Shaped {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- write!(f, "Shaped({})", self.text)
+ Debug::fmt(&self.text, f)
}
}