GridMut

Trait GridMut 

Source
pub trait GridMut<T: Clone>: Grid<T> {
    // Required methods
    fn set_optional(&mut self, x: usize, y: usize, value: T) -> bool;
    fn fill(&mut self, value: T);

    // Provided methods
    fn set(&mut self, x: usize, y: usize, value: T) { ... }
    fn deref_assign<O: Grid<T>>(&mut self, other: &O) { ... }
    fn set_col(
        &mut self,
        x: usize,
        col: &[T],
    ) -> Result<(), SetValueSeriesError> { ... }
    fn set_row(
        &mut self,
        y: usize,
        row: &[T],
    ) -> Result<(), SetValueSeriesError> { ... }
}
Expand description

A two-dimensional mutable grid of T

Required Methods§

Source

fn set_optional(&mut self, x: usize, y: usize, value: T) -> bool

Sets the value at the specified position if the position is inside of bounds

§Arguments
  • x and y: position of the cell to read

returns: true if the value has been set

Source

fn fill(&mut self, value: T)

Sets all cells in the grid to the specified value

Provided Methods§

Source

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

Sets the value at the specified position

§Arguments
  • x and y: position of the cell to read
§Panics

When accessing x or y out of bounds.

Source

fn deref_assign<O: Grid<T>>(&mut self, other: &O)

Fills the grid with the values from the provided grid.

The grids have to match in size exactly.

For 1D slices the equivalent would be *slice = other_slice.

Source

fn set_col(&mut self, x: usize, col: &[T]) -> Result<(), SetValueSeriesError>

Overwrites a column in the grid.

Returns Err if x is out of bounds or col is not of the correct size.

Source

fn set_row(&mut self, y: usize, row: &[T]) -> Result<(), SetValueSeriesError>

Overwrites a row in the grid.

Returns Err if y is out of bounds or row is not of the correct size.

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§

Source§

impl GridMut<bool> for Bitmap

Source§

impl<T: Value> GridMut<T> for ValueGrid<T>

Source§

impl<TElement: Copy, TGrid: GridMut<TElement>> GridMut<TElement> for WindowMut<'_, TElement, TGrid>