diff --git a/crates/emath/src/pos2.rs b/crates/emath/src/pos2.rs index 6e0ef212b..2f3d1bd1b 100644 --- a/crates/emath/src/pos2.rs +++ b/crates/emath/src/pos2.rs @@ -319,7 +319,11 @@ impl Div for Pos2 { impl fmt::Debug for Pos2 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "[{:.1} {:.1}]", self.x, self.y) + if let Some(precision) = f.precision() { + write!(f, "[{1:.0$} {2:.0$}]", precision, self.x, self.y) + } else { + write!(f, "[{:.1} {:.1}]", self.x, self.y) + } } } diff --git a/crates/emath/src/rot2.rs b/crates/emath/src/rot2.rs index f9e0ae646..45d1f0b55 100644 --- a/crates/emath/src/rot2.rs +++ b/crates/emath/src/rot2.rs @@ -91,12 +91,22 @@ impl Rot2 { impl std::fmt::Debug for Rot2 { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "Rot2 {{ angle: {:.1}°, length: {} }}", - self.angle().to_degrees(), - self.length() - ) + if let Some(precision) = f.precision() { + write!( + f, + "Rot2 {{ angle: {:.2$}°, length: {} }}", + self.angle().to_degrees(), + self.length(), + precision + ) + } else { + write!( + f, + "Rot2 {{ angle: {:.1}°, length: {} }}", + self.angle().to_degrees(), + self.length(), + ) + } } } diff --git a/crates/emath/src/vec2.rs b/crates/emath/src/vec2.rs index 29050935f..483de197d 100644 --- a/crates/emath/src/vec2.rs +++ b/crates/emath/src/vec2.rs @@ -468,7 +468,11 @@ impl Div for Vec2 { impl fmt::Debug for Vec2 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "[{:.1} {:.1}]", self.x, self.y) + if let Some(precision) = f.precision() { + write!(f, "[{1:.0$} {2:.0$}]", precision, self.x, self.y) + } else { + write!(f, "[{:.1} {:.1}]", self.x, self.y) + } } }