Trait Grid

Source
pub trait Grid<T: Clone + Copy> {
Show 14 methods // Required methods fn new(width: usize, height: usize, default_value: T) -> Self; fn get(&self, x: usize, y: usize) -> T; fn set(&mut self, x: usize, y: usize, value: T); fn width(&self) -> usize; fn height(&self) -> usize; // Provided methods fn get_point(&self, point: Point) -> T { ... } fn set_point(&mut self, point: Point, value: T) { ... } fn get_ix(&self, x: usize, y: usize) -> usize { ... } fn get_ix_point(&self, point: &Point) -> usize { ... } fn point_in_bounds(&self, point: Point) -> bool { ... } fn index_in_bounds(&self, x: usize, y: usize) -> bool { ... } fn set_rectangle(&mut self, rect: &Rect, value: T) { ... } fn rect(&self) -> Rect { ... } fn get_rect(&self, rect: Rect) -> Vec<T> { ... }
}
Expand description

The Grid trait abstracts over containers of Clone and Copy items laid out in a rectangle with a certain width and height.

Required Methods§

Source

fn new(width: usize, height: usize, default_value: T) -> Self

Source

fn get(&self, x: usize, y: usize) -> T

Source

fn set(&mut self, x: usize, y: usize, value: T)

Source

fn width(&self) -> usize

Source

fn height(&self) -> usize

Provided Methods§

Source

fn get_point(&self, point: Point) -> T

Source

fn set_point(&mut self, point: Point, value: T)

Source

fn get_ix(&self, x: usize, y: usize) -> usize

Gets the index corresponding to a coordinate, which is row-wise.

Source

fn get_ix_point(&self, point: &Point) -> usize

Source

fn point_in_bounds(&self, point: Point) -> bool

Tests whether a point is in bounds.

Source

fn index_in_bounds(&self, x: usize, y: usize) -> bool

Tests whether an index is in bounds.

Source

fn set_rectangle(&mut self, rect: &Rect, value: T)

Sets a given rectangle on the grid to the value.

Source

fn rect(&self) -> Rect

Retrieves the rectangle corresponding to the grid dimensions at the origin.

Source

fn get_rect(&self, rect: Rect) -> Vec<T>

Retrieves a column-wise vector of grid values in the given rectangle.

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§