From 421e03efda040108a6220509512c7f6fbec43a4a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Sat, 5 Nov 2022 21:46:40 +0100 Subject: [PATCH] Simplify `PartialHalfEdge::with_curve` --- crates/fj-kernel/src/algorithms/transform/edge.rs | 2 +- crates/fj-kernel/src/builder/cycle.rs | 2 +- crates/fj-kernel/src/builder/edge.rs | 7 ++----- crates/fj-kernel/src/builder/shell.rs | 2 +- crates/fj-kernel/src/partial/objects/edge.rs | 10 +++------- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/transform/edge.rs b/crates/fj-kernel/src/algorithms/transform/edge.rs index 71c72a8d1..9ff8ca2ac 100644 --- a/crates/fj-kernel/src/algorithms/transform/edge.rs +++ b/crates/fj-kernel/src/algorithms/transform/edge.rs @@ -36,7 +36,7 @@ impl TransformObject for PartialHalfEdge { .into(); Ok(Self::default() - .with_curve(Some(curve)) + .with_curve(curve) .with_vertices(Some(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 afca811b6..e123c457b 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -81,7 +81,7 @@ impl CycleBuilder for PartialCycle { half_edges.push( HalfEdge::partial() - .with_curve(Some(curve)) + .with_curve(curve) .with_vertices(Some([from, to])), ); diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index e3ab4d1d0..8fd977874 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -79,9 +79,7 @@ impl HalfEdgeBuilder for PartialHalfEdge { .with_surface_form(surface_vertex.clone()) }); - Ok(self - .with_curve(Some(curve)) - .with_vertices(Some([back, front]))) + Ok(self.with_curve(curve).with_vertices(Some([back, front]))) } fn update_as_line_segment_from_points( @@ -181,8 +179,7 @@ impl HalfEdgeBuilder for PartialHalfEdge { }) }; - self.with_curve(Some(curve)) - .with_vertices(Some([back, front])) + self.with_curve(curve).with_vertices(Some([back, front])) } } diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 4ae6ef6c8..98c593442 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -148,7 +148,7 @@ impl<'a> ShellBuilder<'a> { )); HalfEdge::partial() - .with_curve(Some(curve)) + .with_curve(curve) .with_vertices(Some([ Vertex::partial().with_surface_form(from), Vertex::partial().with_surface_form(to), diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index e9704695f..26ece8472 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -67,13 +67,9 @@ impl PartialHalfEdge { } /// Update the partial half-edge with the given curve - pub fn with_curve( - mut self, - curve: Option>>, - ) -> Self { - if let Some(curve) = curve { - self.curve = curve.into(); - } + pub fn with_curve(mut self, curve: impl Into>) -> Self { + self.curve = curve.into(); + self }