docs: post-creation neighbor edges, no ignore result err

This commit is contained in:
2025-07-28 13:25:31 -05:00
parent d743aee393
commit bea915b5c7
2 changed files with 4 additions and 6 deletions

View File

@@ -61,11 +61,6 @@ impl Intersection {
[self.up, self.down, self.left, self.right].into_iter().flatten()
}
/// Returns an iterator over all directions that don't have an edge.
pub fn empty_directions(&self) -> impl Iterator<Item = Direction> + '_ {
DIRECTIONS.into_iter().filter(|dir| self.get(*dir).is_none())
}
/// Retrieves the edge in the specified direction, if it exists.
pub fn get(&self, direction: Direction) -> Option<Edge> {
match direction {

View File

@@ -168,12 +168,15 @@ impl Map {
}
}
// While most nodes are already connected to their neighbors, some may not be
for (grid_pos, &node_id) in &grid_to_node {
for dir in DIRECTIONS {
// If the node doesn't have an edge in this direction, look for a neighbor in that direction
if graph.adjacency_list[node_id].get(dir).is_none() {
let neighbor = grid_pos + dir.to_ivec2();
// If the neighbor exists, connect the node to it
if let Some(&neighbor_id) = grid_to_node.get(&neighbor) {
let _ = graph.connect(node_id, neighbor_id, None, dir);
graph.connect(node_id, neighbor_id, None, dir).expect("Failed to add edge");
}
}
}