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
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)
Sourcefn get_ix(&self, x: usize, y: usize) -> usize
fn get_ix(&self, x: usize, y: usize) -> usize
Gets the index corresponding to a coordinate, which is row-wise.
fn get_ix_point(&self, point: &Point) -> usize
Sourcefn point_in_bounds(&self, point: Point) -> bool
fn point_in_bounds(&self, point: Point) -> bool
Tests whether a point is in bounds.
Sourcefn index_in_bounds(&self, x: usize, y: usize) -> bool
fn index_in_bounds(&self, x: usize, y: usize) -> bool
Tests whether an index is in bounds.
Sourcefn set_rectangle(&mut self, rect: &Rect, value: T)
fn set_rectangle(&mut self, rect: &Rect, value: T)
Sets a given rectangle on the grid to the value.
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.