Add early break condition for 2022/day12-part1
This commit is contained in:
parent
5928c3fbb3
commit
6110626937
@ -190,6 +190,13 @@ fn main() {
|
|||||||
// Grab a mutable borrow to the actual node.
|
// Grab a mutable borrow to the actual node.
|
||||||
let current_node = map[current_vn.y][current_vn.x].borrow_mut();
|
let current_node = map[current_vn.y][current_vn.x].borrow_mut();
|
||||||
|
|
||||||
|
// Have we reached the destination?
|
||||||
|
// Then we're done here.
|
||||||
|
if current_node.x == dest_x && current_node.y == dest_y {
|
||||||
|
println!("Found the destination!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Now iterate through all neighbors.
|
// Now iterate through all neighbors.
|
||||||
for nb in ¤t_node.outgoing {
|
for nb in ¤t_node.outgoing {
|
||||||
// Grab a mutable borrow to that neighbor.
|
// Grab a mutable borrow to that neighbor.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user