mirror of
https://github.com/typst/typst
synced 2025-05-21 04:25:28 +08:00
Better debug representations 💻
This commit is contained in:
parent
264a7dedd4
commit
898dc38ec1
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user