Grid

Trait Grid 

Source
pub trait Grid: Debug {
    type OccupiedIterator<'a>: IntoIterator<Item = &'a Cell>
       where Cell: 'a,
             Self: 'a;
    type CornerIterator<'a>: IntoIterator<Item = (&'a Cell, &'a CornerStatus)>
       where Cell: 'a,
             CornerStatus: 'a,
             Self: 'a;

    // Required methods
    fn change_cells(
        &mut self,
        changes: &HashMap<Cell, bool>,
    ) -> (Vec<(Cell, bool)>, Vec<(Cell, CornerStatus)>);
    fn cell_size(&self) -> f64;
    fn is_occupied(&self, cell: &Cell) -> bool;
    fn occupied_cells<'b>(&'b self) -> Self::OccupiedIterator<'b>;
    fn corners<'b>(&'b self) -> Self::CornerIterator<'b>;
    fn is_point_occupied(&self, p: Point) -> Option<Cell>;
    fn is_square_occupied(&self, p: Point, width: f64) -> Option<Cell>;
    fn is_circle_occupied(&self, p: Point, radius: f64) -> Option<Cell>;
    fn is_sweep_occupied(
        &self,
        p0: Point,
        p1: Point,
        width: f64,
    ) -> Option<Cell>;
}

Required Associated Types§

Source

type OccupiedIterator<'a>: IntoIterator<Item = &'a Cell> where Cell: 'a, Self: 'a

Source

type CornerIterator<'a>: IntoIterator<Item = (&'a Cell, &'a CornerStatus)> where Cell: 'a, CornerStatus: 'a, Self: 'a

Required Methods§

Source

fn change_cells( &mut self, changes: &HashMap<Cell, bool>, ) -> (Vec<(Cell, bool)>, Vec<(Cell, CornerStatus)>)

Change the occupancy value of a set of cells. Get back any changes that have occurred to the corners of the occupancy.

Source

fn cell_size(&self) -> f64

Get the size (width and height) of a cell.

Source

fn is_occupied(&self, cell: &Cell) -> bool

Check if a single cell is occupied.

Source

fn occupied_cells<'b>(&'b self) -> Self::OccupiedIterator<'b>

Get an iterator over all occupied cells.

Source

fn corners<'b>(&'b self) -> Self::CornerIterator<'b>

Get an iterator over all corners.

Source

fn is_point_occupied(&self, p: Point) -> Option<Cell>

Check if a point is occupied. If it is, return the cell that occupies it.

Source

fn is_square_occupied(&self, p: Point, width: f64) -> Option<Cell>

Check if a square has any occupancy. The first cell found that occupies the space will be returned.

Source

fn is_circle_occupied(&self, p: Point, radius: f64) -> Option<Cell>

Check if a circle has any occupancy. The first cell found that occupies the circle will be returned.

Source

fn is_sweep_occupied(&self, p0: Point, p1: Point, width: f64) -> Option<Cell>

Check if a rectangular sweep from p0 to p1 with the specified width has any occupancy. The first cell found that occupies the space will be returned.

If p0 is almost equal to p1 then this will simply return the result of is_point_occupied(p0), because there is no way to infer what direction is meant to span the width of the sweep.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§