fn search(dungeon: &Dungeon, visited: &Coords, x: u32, y: u32) -> Coords {
    let mut local = visited.clone();
    assert!(!local.contains(&(x, y)));
    local.insert((x, y));
    for sc in SurroundingCells::new(dungeon, x, y, Surrounding::AllDirections) {
        let new_x = sc.x;
        let new_y = sc.y;
        if is_accessible(&sc) && !local.contains(&(new_x, new_y)) {
            let results = search(&dungeon, &local, new_x, new_y);
            let search_results: Coords = local.union(&results).cloned().collect();
            local = search_results.clone();
        }
    }
    local.clone()
}
// recursively traverse the dungeon (depth-first)
recursively traverse the dungeon (depth-first)
recursively traverse the dungeon ( depth - first )
fn search(dungeon: &Dungeon, visited: &Coords, x: u32, y: u32) -> Coords {
    let mut local = visited.clone();
    assert!(!local.contains(&(x, y)));
    local.insert((x, y));
    for sc in SurroundingCells::new(dungeon, x, y, Surrounding::AllDirections) {
        let new_x = sc.x;
        let new_y = sc.y;
        if is_accessible(&sc) && !local.contains(&(new_x, new_y)) {
            let results = search(&dungeon, &local, new_x, new_y);
            let search_results: Coords = local.union(&results).cloned().collect();
            local = search_results.clone();
        }
    }
    local.clone()
}
fn search ( dungeon : & Dungeon , visited : & Coords , x : u32 , y : u32 ) -> Coords { let mut local = visited . clone ( ) ; assert ! ( local contains ( ( x y ) ) ) ; local . insert ( ( x , y ) ) ; for sc in SurroundingCells :: new ( dungeon , x , y , Surrounding :: AllDirections ) { let new_x = sc . x ; let new_y = sc . y ; if is_accessible ( & sc ) && ! local . contains ( & ( new_x , new_y ) ) { let results = search ( & dungeon , & local , new_x , new_y ) ; let search_results : Coords = local . union ( & results ) . cloned ( ) . collect ( ) ; local = search_results . clone ( ) ; } } local . clone ( ) }
recursively traverse the dungeon (depth-first)
recursively traverse the dungeon ( depth - first )
dungeon
&Dungeon
visited
&Coords
x
u32
y
u32