From de90327970194b1bef4071a3aa0df3156e0269f1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 22 May 2024 19:55:53 +0200 Subject: [PATCH] Inline redundant struct --- crates/fj-core/src/validate/shell.rs | 57 ++++++++++------------------ 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 88c4ca889..97b1fcc64 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -84,13 +84,10 @@ impl ShellValidationError { ) .all(|d| d < config.distinct_min_distance) { - let boundaries = CoincidentHalfEdgeBoundaries { - boundaries: [half_edge_a, half_edge_b].map( - |half_edge| { - geometry.of_half_edge(half_edge).boundary - }, - ), - }; + let boundaries = + [half_edge_a, half_edge_b].map(|half_edge| { + geometry.of_half_edge(half_edge).boundary + }); let curves = CoincidentHalfEdgeCurves { curves: [half_edge_a, half_edge_b] .map(|half_edge| half_edge.curve().clone()), @@ -126,7 +123,7 @@ impl ShellValidationError { #[derive(Clone, Debug, thiserror::Error)] pub struct CoincidentHalfEdgesAreNotSiblings { /// The boundaries of the half-edges - pub boundaries: CoincidentHalfEdgeBoundaries, + pub boundaries: [CurveBoundary>; 2], /// The curves of the half-edges pub curves: CoincidentHalfEdgeCurves, @@ -149,45 +146,31 @@ impl fmt::Display for CoincidentHalfEdgesAreNotSiblings { siblings", )?; + { + let [a, b] = &self.boundaries; + + if a != &b.reverse() { + writeln!( + f, + "Boundaries don't match.\n\ + \tHalf-edge 1 has boundary `{a:?}`\n\ + \tHalf-edge 2 has boundary `{b:?}`\n\ + \t(expecting same boundary, but reversed)" + )?; + } + } + write!( f, "{}\ {}\ - {}\ Half-edge 1: {:#?}\n\ Half-edge 2: {:#?}", - self.boundaries, - self.curves, - self.vertices, - self.half_edge_a, - self.half_edge_b, + self.curves, self.vertices, self.half_edge_a, self.half_edge_b, ) } } -#[derive(Clone, Debug)] -pub struct CoincidentHalfEdgeBoundaries { - pub boundaries: [CurveBoundary>; 2], -} - -impl fmt::Display for CoincidentHalfEdgeBoundaries { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let [a, b] = &self.boundaries; - - if a != &b.reverse() { - writeln!( - f, - "Boundaries don't match.\n\ - \tHalf-edge 1 has boundary `{a:?}`\n\ - \tHalf-edge 2 has boundary `{b:?}`\n\ - \t(expecting same boundary, but reversed)" - )?; - } - - Ok(()) - } -} - #[derive(Clone, Debug)] pub struct CoincidentHalfEdgeCurves { pub curves: [Handle; 2],