From ad87bd46dadec6e5fb42af214973a6081d8c1d33 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 14:43:07 +0100 Subject: [PATCH] Change style of `update_as_circle_from_radius` --- crates/fj-kernel/src/algorithms/approx/curve.rs | 9 ++++----- crates/fj-kernel/src/builder/curve.rs | 16 ++++++++++------ crates/fj-kernel/src/builder/edge.rs | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/curve.rs b/crates/fj-kernel/src/algorithms/approx/curve.rs index aa17fc9b7..870925bcc 100644 --- a/crates/fj-kernel/src/algorithms/approx/curve.rs +++ b/crates/fj-kernel/src/algorithms/approx/curve.rs @@ -291,13 +291,12 @@ mod tests { let surface = objects .surfaces .insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]))?; - let curve = PartialCurve { + let mut curve = PartialCurve { surface: Some(surface), ..Default::default() - } - .update_as_circle_from_radius(1.) - .build(&objects)? - .insert(&objects)?; + }; + curve.update_as_circle_from_radius(1.); + let curve = curve.build(&objects)?.insert(&objects)?; let range = RangeOnPath::from([[0.], [TAU]]); let tolerance = 1.; diff --git a/crates/fj-kernel/src/builder/curve.rs b/crates/fj-kernel/src/builder/curve.rs index a16324b32..9afedb650 100644 --- a/crates/fj-kernel/src/builder/curve.rs +++ b/crates/fj-kernel/src/builder/curve.rs @@ -11,7 +11,10 @@ pub trait CurveBuilder { fn update_as_v_axis(self) -> Self; /// Update partial curve as a circle, from the provided radius - fn update_as_circle_from_radius(self, radius: impl Into) -> Self; + fn update_as_circle_from_radius( + &mut self, + radius: impl Into, + ) -> &mut Self; /// Update partial curve as a line, from the provided points fn update_as_line_from_points( @@ -37,11 +40,12 @@ impl CurveBuilder for PartialCurve { self } - fn update_as_circle_from_radius(self, radius: impl Into) -> Self { - Self { - path: Some(SurfacePath::circle_from_radius(radius)), - ..self - } + fn update_as_circle_from_radius( + &mut self, + radius: impl Into, + ) -> &mut Self { + self.path = Some(SurfacePath::circle_from_radius(radius)); + self } fn update_as_line_from_points( diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index c05c65120..2fc232795 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -70,7 +70,7 @@ impl HalfEdgeBuilder for PartialHalfEdge { ) -> Result { let mut curve = self.curve().into_partial(); curve.global_form = Some(self.extract_global_curve()); - let curve = curve.update_as_circle_from_radius(radius); + curve.update_as_circle_from_radius(radius); let path = curve.path.expect("Expected path that was just created");