pub trait SurfaceGrid<T>: IndexMut<Self::Point> + Index<Self::Point, Output = T> + IntoIterator<Item = (Self::Point, T)> {
    type Point: GridPoint;

    // Required methods
    fn from_fn<F: FnMut(&Self::Point) -> T>(f: F) -> Self;
    fn set_from_fn<F: FnMut(&Self::Point) -> T>(&mut self, f: F);
    fn iter<'a>(&'a self) -> impl Iterator<Item = (Self::Point, &'a T)>
       where T: 'a;
    fn points(&self) -> impl Iterator<Item = Self::Point>;

    // Provided methods
    fn map_neighbours<F: FnMut(&T, &T, &T, &T, &T) -> T>(&self, f: F) -> Self
       where Self: Sized { ... }
    fn map_neighbours_diagonals<F: FnMut(&T, &T, &T, &T, &T, &T, &T, &T, &T) -> T>(
        &self,
        f: F
    ) -> Self
       where Self: Sized { ... }
    fn set_from_neighbours<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&U, &U, &U, &U, &U) -> T>(
        &mut self,
        source: &G,
        f: F
    ) { ... }
    fn set_from_neighbours_diagonals<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&U, &U, &U, &U, &U, &U, &U, &U, &U) -> T>(
        &mut self,
        source: &G,
        f: F
    ) { ... }
}
Expand description

A grid wrapped around a surface.

Required Associated Types§

source

type Point: GridPoint

The type of a point on this grid.

Required Methods§

source

fn from_fn<F: FnMut(&Self::Point) -> T>(f: F) -> Self

Creates a new surface grid by calling the specified function for each point in the grid.

  • f - The function to apply.
source

fn set_from_fn<F: FnMut(&Self::Point) -> T>(&mut self, f: F)

Updates this surface grid by calling the specified function for each point in the grid.

  • f - The function to apply.
source

fn iter<'a>(&'a self) -> impl Iterator<Item = (Self::Point, &'a T)>
where T: 'a,

Iterates over the points in this grid and their values.

source

fn points(&self) -> impl Iterator<Item = Self::Point>

Iterates over the points in this grid.

Provided Methods§

source

fn map_neighbours<F: FnMut(&T, &T, &T, &T, &T) -> T>(&self, f: F) -> Self
where Self: Sized,

Applies a function to each cell and its direct neighbours.

The provided function is called with the arguments: current, up, down, left, right.

f - The function to apply.

source

fn map_neighbours_diagonals<F: FnMut(&T, &T, &T, &T, &T, &T, &T, &T, &T) -> T>( &self, f: F ) -> Self
where Self: Sized,

Applies a function to each cell and its direct neighbours including diagonals.

The provided function is called with the arguments: up_left, up, up_right, left, current, right, down_left, down, down_right.

f - The function to apply.

source

fn set_from_neighbours<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&U, &U, &U, &U, &U) -> T>( &mut self, source: &G, f: F )

Applies a function to each cell and its direct neighbours.

The provided function is called with the arguments: current, up, down, left, right.

source - The source grid from which to read data. f - The function to apply.

source

fn set_from_neighbours_diagonals<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&U, &U, &U, &U, &U, &U, &U, &U, &U) -> T>( &mut self, source: &G, f: F )

Applies a function to each cell and its direct neighbours including diagonals.

The provided function is called with the arguments: up_left, up, up_right, left, current, right, down_left, down, down_right.

source - The source grid from which to read data. f - The function to apply.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T, const W: usize, const H: usize> SurfaceGrid<T> for RectangleSphereGrid<T, W, H>

source§

impl<T: Debug, const S: usize> SurfaceGrid<T> for CubeSphereGrid<T, S>