Skip to content

Commit

Permalink
Merge #421
Browse files Browse the repository at this point in the history
421: Reformat with let/else support r=samueltardieu a=samueltardieu



Co-authored-by: Samuel Tardieu <[email protected]>
  • Loading branch information
bors[bot] and samueltardieu authored Jul 20, 2023
2 parents 6c1c13b + e55f770 commit ce0a70b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/directed/yen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ where
IN: IntoIterator<Item = (N, C)>,
FS: FnMut(&N) -> bool,
{
let Some((n, c)) = dijkstra_internal(start, &mut successors, &mut success) else { return vec![]; };
let Some((n, c)) = dijkstra_internal(start, &mut successors, &mut success) else {
return vec![];
};

let mut visited = HashSet::new();
// A vector containing our paths.
Expand Down Expand Up @@ -171,9 +173,13 @@ where
// If we have other potential best routes with the same cost, we can insert
// them in the found routes since we will not find a better alternative.
while routes.len() < k {
let Some(k_route) = k_routes.peek() else { break; };
let Some(k_route) = k_routes.peek() else {
break;
};
if k_route.0.cost == cost {
let Some(k_route) = k_routes.pop() else { break; }; // Cannot break
let Some(k_route) = k_routes.pop() else {
break; // Cannot break
};
routes.push(k_route.0);
} else {
break; // Other routes have higher cost
Expand Down

0 comments on commit ce0a70b

Please sign in to comment.