From a4c6a71f3d836ceb0db7bf369a1804ce8d79da89 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 13 Jun 2022 16:21:36 +0200 Subject: [PATCH] Remove redundant constructor --- crates/fj-kernel/src/shape/api.rs | 22 ++++++++++++---------- crates/fj-kernel/src/shape/object.rs | 8 ++++---- crates/fj-kernel/src/topology/builder.rs | 16 ++++++++-------- crates/fj-kernel/src/topology/edge.rs | 8 -------- crates/fj-operations/src/difference_2d.rs | 6 +++--- 5 files changed, 27 insertions(+), 33 deletions(-) diff --git a/crates/fj-kernel/src/shape/api.rs b/crates/fj-kernel/src/shape/api.rs index c5c5f16ba..eb02f3242 100644 --- a/crates/fj-kernel/src/shape/api.rs +++ b/crates/fj-kernel/src/shape/api.rs @@ -319,8 +319,10 @@ mod tests { assert!(shape.get_handle(&surface.get()).as_ref() == Some(&surface)); let vertex = Vertex { point }; - let edge = - Edge::new(LocalForm::canonical_only(curve), VerticesOfEdge::none()); + let edge = Edge { + curve: LocalForm::canonical_only(curve), + vertices: VerticesOfEdge::none(), + }; assert!(shape.get_handle(&vertex).is_none()); assert!(shape.get_handle(&edge).is_none()); @@ -376,10 +378,10 @@ mod tests { // Shouldn't work. Nothing has been added to `shape`. let err = shape - .insert(Edge::new( - LocalForm::canonical_only(curve.clone()), - VerticesOfEdge::from_vertices([a.clone(), b.clone()]), - )) + .insert(Edge { + curve: LocalForm::canonical_only(curve.clone()), + vertices: VerticesOfEdge::from_vertices([a.clone(), b.clone()]), + }) .unwrap_err(); assert!(err.missing_curve(&curve)); assert!(err.missing_vertex(&a.canonical())); @@ -393,10 +395,10 @@ mod tests { let b = LocalForm::new(Point::from([2.]), b); // Everything has been added to `shape` now. Should work! - shape.insert(Edge::new( - LocalForm::canonical_only(curve), - VerticesOfEdge::from_vertices([a, b]), - ))?; + shape.insert(Edge { + curve: LocalForm::canonical_only(curve), + vertices: VerticesOfEdge::from_vertices([a, b]), + })?; Ok(()) } diff --git a/crates/fj-kernel/src/shape/object.rs b/crates/fj-kernel/src/shape/object.rs index 4e72844ba..29142939f 100644 --- a/crates/fj-kernel/src/shape/object.rs +++ b/crates/fj-kernel/src/shape/object.rs @@ -108,10 +108,10 @@ impl Object for Edge<3> { Ok(LocalForm::new(*vertex.local(), canonical)) })?; - let merged = shape.get_handle_or_insert(Edge::new( - LocalForm::canonical_only(curve), - VerticesOfEdge::new(vertices), - ))?; + let merged = shape.get_handle_or_insert(Edge { + curve: LocalForm::canonical_only(curve), + vertices: VerticesOfEdge::new(vertices), + })?; if let Some(handle) = handle { mapping.edges.insert(handle, merged.clone()); diff --git a/crates/fj-kernel/src/topology/builder.rs b/crates/fj-kernel/src/topology/builder.rs index 2bb79d27a..d52832f31 100644 --- a/crates/fj-kernel/src/topology/builder.rs +++ b/crates/fj-kernel/src/topology/builder.rs @@ -66,10 +66,10 @@ impl<'r> EdgeBuilder<'r> { curve: LocalForm::new(curve_local, curve_canonical.clone()), vertices: VerticesOfEdge::none(), }; - let edge_canonical = self.shape.insert(Edge::new( - LocalForm::canonical_only(curve_canonical), - VerticesOfEdge::none(), - ))?; + let edge_canonical = self.shape.insert(Edge { + curve: LocalForm::canonical_only(curve_canonical), + vertices: VerticesOfEdge::none(), + })?; Ok(LocalForm::new(edge_local, edge_canonical)) } @@ -109,10 +109,10 @@ impl<'r> EdgeBuilder<'r> { LocalForm::new(Point::from([1.]), b), ]; - let edge = self.shape.insert(Edge::new( - LocalForm::canonical_only(curve), - VerticesOfEdge::from_vertices(vertices), - ))?; + let edge = self.shape.insert(Edge { + curve: LocalForm::canonical_only(curve), + vertices: VerticesOfEdge::from_vertices(vertices), + })?; Ok(edge) } diff --git a/crates/fj-kernel/src/topology/edge.rs b/crates/fj-kernel/src/topology/edge.rs index f2dd8e08d..cf0446af8 100644 --- a/crates/fj-kernel/src/topology/edge.rs +++ b/crates/fj-kernel/src/topology/edge.rs @@ -38,14 +38,6 @@ pub struct Edge { } impl Edge { - /// Construct an instance of `Edge` - pub fn new( - curve: LocalForm, Curve<3>>, - vertices: VerticesOfEdge, - ) -> Self { - Self { curve, vertices } - } - /// Access the curve that the edge refers to /// /// This is a convenience method that saves the caller from dealing with the diff --git a/crates/fj-operations/src/difference_2d.rs b/crates/fj-operations/src/difference_2d.rs index cc7d8e37e..5a36d1120 100644 --- a/crates/fj-operations/src/difference_2d.rs +++ b/crates/fj-operations/src/difference_2d.rs @@ -121,10 +121,10 @@ fn add_cycle( curve: LocalForm::new(curve_local, curve_canonical.clone()), vertices: vertices.clone(), }; - let edge_canonical = shape.merge(Edge::new( - LocalForm::canonical_only(curve_canonical), + let edge_canonical = shape.merge(Edge { + curve: LocalForm::canonical_only(curve_canonical), vertices, - ))?; + })?; edges.push(LocalForm::new(edge_local, edge_canonical)); }