From 5ccea9e80e13c3dbf24d7d205dc2583e9ae9da5a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Sat, 5 Nov 2022 21:49:12 +0100 Subject: [PATCH] Simplify `PartialHalfEdge::with_vertices` --- crates/fj-kernel/src/algorithms/transform/edge.rs | 2 +- crates/fj-kernel/src/builder/cycle.rs | 2 +- crates/fj-kernel/src/builder/edge.rs | 6 +++--- crates/fj-kernel/src/builder/shell.rs | 12 ++++++------ crates/fj-kernel/src/partial/objects/edge.rs | 7 ++----- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/transform/edge.rs b/crates/fj-kernel/src/algorithms/transform/edge.rs index 9ff8ca2ac..265baa084 100644 --- a/crates/fj-kernel/src/algorithms/transform/edge.rs +++ b/crates/fj-kernel/src/algorithms/transform/edge.rs @@ -37,7 +37,7 @@ impl TransformObject for PartialHalfEdge { Ok(Self::default() .with_curve(curve) - .with_vertices(Some(vertices)) + .with_vertices(vertices) .with_global_form(global_form)) } } diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index e123c457b..0052f9f98 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -82,7 +82,7 @@ impl CycleBuilder for PartialCycle { half_edges.push( HalfEdge::partial() .with_curve(curve) - .with_vertices(Some([from, to])), + .with_vertices([from, to]), ); continue; diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index 8fd977874..f8e258842 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -79,7 +79,7 @@ impl HalfEdgeBuilder for PartialHalfEdge { .with_surface_form(surface_vertex.clone()) }); - Ok(self.with_curve(curve).with_vertices(Some([back, front]))) + Ok(self.with_curve(curve).with_vertices([back, front])) } fn update_as_line_segment_from_points( @@ -96,7 +96,7 @@ impl HalfEdgeBuilder for PartialHalfEdge { }); self.with_surface(surface) - .with_vertices(Some(vertices)) + .with_vertices(vertices) .update_as_line_segment() } @@ -179,7 +179,7 @@ impl HalfEdgeBuilder for PartialHalfEdge { }) }; - self.with_curve(curve).with_vertices(Some([back, front])) + self.with_curve(curve).with_vertices([back, front]) } } diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 98c593442..59007984d 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -112,10 +112,10 @@ impl<'a> ShellBuilder<'a> { .with_surface(Some(surface.clone())); HalfEdge::partial() - .with_vertices(Some([ + .with_vertices([ Vertex::partial().with_surface_form(from), Vertex::partial().with_surface_form(to), - ])) + ]) .update_as_line_segment() .build(self.objects) .unwrap() @@ -149,10 +149,10 @@ impl<'a> ShellBuilder<'a> { HalfEdge::partial() .with_curve(curve) - .with_vertices(Some([ + .with_vertices([ Vertex::partial().with_surface_form(from), Vertex::partial().with_surface_form(to), - ])) + ]) .update_as_line_segment() .build(self.objects) .unwrap() @@ -175,7 +175,7 @@ impl<'a> ShellBuilder<'a> { let to = Vertex::partial().with_surface_form(to); HalfEdge::partial() - .with_vertices(Some([from, to])) + .with_vertices([from, to]) .update_as_line_segment() .build(self.objects) .unwrap() @@ -251,7 +251,7 @@ impl<'a> ShellBuilder<'a> { edges.push( HalfEdge::partial() - .with_vertices(Some(vertices)) + .with_vertices(vertices) .with_global_form(Some(edge.global_form().clone())) .update_as_line_segment() .build(self.objects) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 26ece8472..19161235f 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -98,12 +98,9 @@ impl PartialHalfEdge { /// Update the partial half-edge with the given vertices pub fn with_vertices( mut self, - vertices: Option<[impl Into>; 2]>, + vertices: [impl Into>; 2], ) -> Self { - let vertices = vertices.map(|vertices| vertices.map(Into::into)); - if let Some([back, front]) = vertices { - self.vertices = [back, front]; - } + self.vertices = vertices.map(Into::into); self }