From bea915b5c73f909d1b995b86e917979a6ae2d937 Mon Sep 17 00:00:00 2001 From: Xevion Date: Mon, 28 Jul 2025 13:25:31 -0500 Subject: [PATCH] docs: post-creation neighbor edges, no ignore result err --- src/entity/graph.rs | 5 ----- src/map.rs | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/entity/graph.rs b/src/entity/graph.rs index 709b84c..a721dda 100644 --- a/src/entity/graph.rs +++ b/src/entity/graph.rs @@ -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 + '_ { - 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 { match direction { diff --git a/src/map.rs b/src/map.rs index a13e646..049b0d3 100644 --- a/src/map.rs +++ b/src/map.rs @@ -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"); } } }