Skip to content

Commit

Permalink
Cleanup unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Walrus committed Mar 16, 2023
1 parent 3e0efd9 commit 7eb19cd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/fj-kernel/src/validate/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,15 @@ impl CycleValidationError {
config: &ValidationConfig,
errors: &mut Vec<ValidationError>,
) {
// If there are less than two half edges
if cycle.half_edges().nth(1).is_none() {
errors.push(Self::NotEnoughHalfEdges.into());
return;
}
for (first, second) in cycle
.half_edges()
// Chain the first half_edge so that we make sure that the last connects to the first.
// This unwrap will never fail because we checked before that there are enough half_edges.
.chain(std::iter::once(cycle.half_edges().next().unwrap()))
.tuple_windows()
{
Expand Down

0 comments on commit 7eb19cd

Please sign in to comment.