fn _distance(&self, a: &Coord, b: &Coord, visited: &mut Vec<Vec<bool>>) -> Option<usize> {
        if a == b {
            return Some(0);
        }

        let neighbors = a.neighbors_by_direction(b);
        let water_neighbors = neighbors.iter().filter(|&coord| self.is_water(&coord));

        for coord in water_neighbors {
            if visited[coord.y][coord.x] {
                continue;
            }
            visited[coord.y][coord.x] = true;

            match self._distance(coord, b, visited) {
                Some(distance) => return Some(distance + 1),
                None => continue,
            }
        }
        None
    }
// invariant: a, b are coords to water cells
a, b are coords to water cells
a b are coords to water cells
fn _distance(&self, a: &Coord, b: &Coord, visited: &mut Vec<Vec<bool>>) -> Option<usize> {
        if a == b {
            return Some(0);
        }
        let neighbors = a.neighbors_by_direction(b);
        let water_neighbors = neighbors.iter().filter(|&coord| self.is_water(&coord));
        for coord in water_neighbors {
            if visited[coord.y][coord.x] {
                continue;
            }
            visited[coord.y][coord.x] = true;
            match self._distance(coord, b, visited) {
                Some(distance) => return Some(distance + 1),
                None => continue,
            }
        }
        None
    }
fn _distance ( & self , a : & Coord , b : & Coord , visited : & mut Vec < Vec < bool > > ) -> Option < usize > { if a == b { return Some ( 0 ) ; } let neighbors = a . neighbors_by_direction ( b ) ; let water_neighbors = neighbors . iter ( ) . filter ( | & coord | self . is_water ( & coord ) ) ; for coord in water_neighbors { if visited [ coord . y ] [ coord . x ] { continue ; } visited [ coord . y ] [ coord . x ] = true ; match self . _distance ( coord , b , visited ) { Some ( distance ) => return Some ( distance + 1 ) , None => continue , } } None }
invariant: a, b are coords to water cells
invariant : a b are coords to water cells
&self
a
&Coord
b
&Coord
visited
&mut Vec<Vec<bool>>
&self
a
&Coord
b
&Coord
visited
&mut Vec<Vec<bool>>