From 842cf1e82965ba80ae1e069254499dab4cd0b4be Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Mon, 3 Mar 2025 16:59:12 -0500 Subject: [PATCH] Add custom Debug impl for Coord Specifically so that we when we debug print these types we don't see a bunch of mentions of PhantomData Space>, which is both an implementation detail and totally uninformative. --- fontdrasil/src/coords.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fontdrasil/src/coords.rs b/fontdrasil/src/coords.rs index a539ee2a..3cc01b31 100644 --- a/fontdrasil/src/coords.rs +++ b/fontdrasil/src/coords.rs @@ -56,7 +56,7 @@ pub struct UserSpace; pub struct NormalizedSpace; /// A coordinate in some coordinate space. -#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Serialize, Deserialize, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Coord { coord: OrderedFloat, // we want to be covariant but also Send + Sync. See @@ -64,6 +64,15 @@ pub struct Coord { space: PhantomData Space>, } +impl Debug for Coord { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Coord") + .field("coord", &self.coord) + .field("space", &Space::default()) + .finish() + } +} + /// A coordinate in design space. pub type DesignCoord = Coord; /// A coordinate in user space