Skip to content

Commit

Permalink
Remove redundant constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed May 24, 2022
1 parent 8758895 commit 4070261
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
10 changes: 5 additions & 5 deletions crates/fj-kernel/src/shape/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ mod tests {
assert!(shape.get_handle(&curve.get()).as_ref() == Some(&curve));
assert!(shape.get_handle(&surface.get()).as_ref() == Some(&surface));

let vertex = Vertex::new(point);
let vertex = Vertex { point };
let edge = Edge::new(curve, None);

assert!(shape.get_handle(&vertex).is_none());
Expand Down Expand Up @@ -326,23 +326,23 @@ mod tests {
let mut other = Shape::new();

let point = shape.insert(Point::from([0., 0., 0.]))?;
shape.insert(Vertex::new(point))?;
shape.insert(Vertex { point })?;

// Should fail, as `point` is not part of the shape.
let point = other.insert(Point::from([1., 0., 0.]))?;
let result = shape.insert(Vertex::new(point));
let result = shape.insert(Vertex { point });
assert!(matches!(result, Err(ValidationError::Structural(_))));

// `point` is too close to the original point. `assert!` is commented,
// because that only causes a warning to be logged right now.
let point = shape.insert(Point::from([5e-8, 0., 0.]))?;
let result = shape.insert(Vertex::new(point));
let result = shape.insert(Vertex { point });
assert!(matches!(result, Err(ValidationError::Uniqueness(_))));

// `point` is farther than `MIN_DISTANCE` away from original point.
// Should work.
let point = shape.insert(Point::from([5e-6, 0., 0.]))?;
shape.insert(Vertex::new(point))?;
shape.insert(Vertex { point })?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/shape/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Object for Vertex {
) -> ValidationResult<Self> {
let point =
self.point().merge_into(Some(self.point), shape, mapping)?;
let merged = shape.get_handle_or_insert(Vertex::new(point))?;
let merged = shape.get_handle_or_insert(Vertex { point })?;

if let Some(handle) = handle {
mapping.vertices.insert(handle, merged.clone());
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/topology/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl<'r> VertexBuilder<'r> {
point: impl Into<Point<3>>,
) -> ValidationResult<Vertex> {
let point = self.shape.get_handle_or_insert(point.into())?;
let vertex = self.shape.get_handle_or_insert(Vertex::new(point))?;
let vertex = self.shape.get_handle_or_insert(Vertex { point })?;

Ok(vertex)
}
Expand Down
5 changes: 0 additions & 5 deletions crates/fj-kernel/src/topology/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ pub struct Vertex {
}

impl Vertex {
/// Construct a new instance of `Vertex`
pub fn new(point: Handle<Point<3>>) -> Self {
Self { point }
}

/// Build a vertex using the [`VertexBuilder`] API
pub fn builder(shape: &mut Shape) -> VertexBuilder {
VertexBuilder::new(shape)
Expand Down

0 comments on commit 4070261

Please sign in to comment.