fn ship_is_next_to(&self, pos: &[u8; 2]) -> bool {
        let &[x, y] = pos;

        // Left
        x > 0 && self.ship_is_in_space(&[x - 1, y])
            // Right
            || x < self.grid_size[0] - 1 && self.ship_is_in_space(&[x + 1, y])
            // Above
            || y > 0 && self.ship_is_in_space(&[x, y - 1])
            // Below
            || y < self.grid_size[1] - 1 && self.ship_is_in_space(&[x, y + 1])
    }
/// Returns whether there is a ship next to the specified grid coordinates.
Returns whether there is a ship next to the specified grid coordinates.
Returns whether there is a ship next to the specified grid coordinates .
fn ship_is_next_to(&self, pos: &[u8; 2]) -> bool {
        let &[x, y] = pos;
        // Left
        x > 0 && self.ship_is_in_space(&[x - 1, y])
            // Right
            || x < self.grid_size[0] - 1 && self.ship_is_in_space(&[x + 1, y])
            // Above
            || y > 0 && self.ship_is_in_space(&[x, y - 1])
            // Below
            || y < self.grid_size[1] - 1 && self.ship_is_in_space(&[x, y + 1])
    }
fn ship_is_next_to ( & self , pos : & [ u8 ; 2 ] ) -> bool { let & [ x , y ] = pos ; // Left x > 0 && self . ship_is_in_space ( & [ x - 1 , y ] ) // Right || x < self . grid_size [ 0 ] - 1 && self . ship_is_in_space ( & [ x + 1 , y ] ) // Above || y > 0 && self . ship_is_in_space ( & [ x , y - 1 ] ) // Below || y < self . grid_size [ 1 ] - 1 && self . ship_is_in_space ( & [ x , y + 1 ] ) }
Returns whether there is a ship next to the specified grid coordinates.
Returns whether there is a ship next to the specified grid coordinates .
&self
pos
&[u8; 2]
&self
pos
&[u8; 2]