Skip to content

Commit

Permalink
Simplify method return value
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Oct 28, 2022
1 parent 507cc2f commit e1b0625
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/partial/maybe_partial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ impl MaybePartial<HalfEdge> {
}

/// Access the vertices
pub fn vertices(&self) -> [Option<MaybePartial<Vertex>>; 2] {
pub fn vertices(&self) -> [MaybePartial<Vertex>; 2] {
match self {
Self::Full(full) => {
full.vertices().clone().map(|vertex| Some(vertex.into()))
full.vertices().clone().map(|vertex| vertex.into())
}
Self::Partial(partial) => partial.vertices.clone().map(Some),
Self::Partial(partial) => partial.vertices.clone(),
}
}
}
Expand Down
13 changes: 3 additions & 10 deletions crates/fj-kernel/src/partial/objects/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ impl PartialCycle {
.half_edges
.last()
.map(|half_edge| {
let [_, last] = half_edge.vertices().map(|vertex| {
vertex.expect("Need half-edge vertices to extend cycle")
});
let [_, last] = half_edge.vertices();
last.surface_form()
})
.into_iter()
Expand Down Expand Up @@ -129,13 +127,8 @@ impl PartialCycle {
let first = self.half_edges.first();
let last = self.half_edges.last();

let vertices = [first, last].map(|option| {
option.map(|half_edge| {
half_edge
.vertices()
.map(|vertex| vertex.expect("Need vertices to close cycle"))
})
});
let vertices = [first, last]
.map(|option| option.map(|half_edge| half_edge.vertices()));

if let [Some([first, _]), Some([_, last])] = vertices {
let vertices = [last, first].map(|vertex| {
Expand Down

0 comments on commit e1b0625

Please sign in to comment.