diff --git a/crates/fj-kernel/src/storage/handle.rs b/crates/fj-kernel/src/storage/handle.rs index 50838b3ee..c4d169558 100644 --- a/crates/fj-kernel/src/storage/handle.rs +++ b/crates/fj-kernel/src/storage/handle.rs @@ -39,16 +39,6 @@ impl Handle { { self.deref().clone() } - - /// Return a `Debug` implementation with full debug info - pub fn full_debug(&self) -> impl fmt::Debug - where - T: fmt::Debug, - { - // It would be nicer to return a struct that implements `Debug`, as that - // would cut down on allocations, but this will work for now. - format!("{:?} -> {:?}", self.id(), self.deref()) - } } impl Deref for Handle { @@ -138,7 +128,10 @@ where } } -impl fmt::Debug for Handle { +impl fmt::Debug for Handle +where + T: fmt::Debug, +{ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let name = { let type_name = type_name::(); @@ -148,8 +141,13 @@ impl fmt::Debug for Handle { } }; let id = self.id().0; + let object = self.deref(); - write!(f, "{name} @ {id:#x}")?; + if f.alternate() { + write!(f, "{name} @ {id:#x} => {object:#?}")?; + } else { + write!(f, "{name} @ {id:#x}")?; + } Ok(()) } @@ -272,7 +270,10 @@ impl PartialOrd for HandleWrapper { } } -impl fmt::Debug for HandleWrapper { +impl fmt::Debug for HandleWrapper +where + T: fmt::Debug, +{ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.0.fmt(f) } diff --git a/crates/fj-kernel/src/validate/edge.rs b/crates/fj-kernel/src/validate/edge.rs index 32f06705b..9fd723aa8 100644 --- a/crates/fj-kernel/src/validate/edge.rs +++ b/crates/fj-kernel/src/validate/edge.rs @@ -45,10 +45,8 @@ pub enum HalfEdgeValidationError { /// [`HalfEdge`] vertices are not defined on the same `Curve` #[error( "`HalfEdge` vertices are not defined on the same `Curve`\n\ - - `Curve` of back vertex: {:?}\n\ - - `Curve` of front vertex: {:?}", - .back_curve.full_debug(), - .front_curve.full_debug(), + - `Curve` of back vertex: {back_curve:#?}\n\ + - `Curve` of front vertex: {front_curve:#?}" )] CurveMismatch { /// The curve of the [`HalfEdge`]'s back vertex @@ -62,10 +60,8 @@ pub enum HalfEdgeValidationError { #[error( "Global form of `HalfEdge`'s `Curve` does not match `GlobalCurve` of \n\ the `HalfEdge`'s `GlobalEdge`\n\ - - `GlobalCurve` from `Curve`: {:?}\n\ - - `GlobalCurve` from `GlobalEdge`: {:?}", - .global_curve_from_curve.full_debug(), - .global_curve_from_global_form.full_debug(), + - `GlobalCurve` from `Curve`: {global_curve_from_curve:#?}\n\ + - `GlobalCurve` from `GlobalEdge`: {global_curve_from_global_form:#?}", )] GlobalCurveMismatch { /// The [`GlobalCurve`] from the [`HalfEdge`]'s [`Curve`] @@ -79,14 +75,10 @@ pub enum HalfEdgeValidationError { #[error( "Global forms of `HalfEdge` vertices do not match vertices of \n\ `HalfEdge`'s global form\n\ - - `GlobalVertex` objects from `Vertex` objects: {:?}\n\ - - `GlobalVertex` objects from `GlobalEdge`: {:?}", - .global_vertices_from_vertices - .each_ref_ext() - .map(|vertex| vertex.full_debug()), - .global_vertices_from_global_form - .each_ref_ext() - .map(|vertex| vertex.full_debug()), + - `GlobalVertex` objects from `Vertex` objects: \ + {global_vertices_from_vertices:#?}\n\ + - `GlobalVertex` objects from `GlobalEdge`: \ + {global_vertices_from_global_form:#?}" )] GlobalVertexMismatch { /// The [`GlobalVertex`] from the [`HalfEdge`]'s vertices diff --git a/crates/fj-kernel/src/validate/vertex.rs b/crates/fj-kernel/src/validate/vertex.rs index 86ec9dc3c..d4fd9c86a 100644 --- a/crates/fj-kernel/src/validate/vertex.rs +++ b/crates/fj-kernel/src/validate/vertex.rs @@ -51,10 +51,8 @@ pub enum VertexValidationError { /// Mismatch between the surface's of the curve and surface form #[error( "Surface form of vertex must be defined on same surface as curve\n\ - `- Surface` of curve: {:?}\n\ - `- Surface` of surface form: {:?}", - .curve_surface.full_debug(), - .surface_form_surface.full_debug(), + `- Surface` of curve: {curve_surface:#?}\n\ + `- Surface` of surface form: {surface_form_surface:#?}" )] SurfaceMismatch { /// The surface of the vertex' curve