[][src]Trait gridly::prelude::Grid

pub trait Grid: GridBounds {
    type Item;
    unsafe fn get_unchecked(&self, location: &Location) -> &Self::Item;

    fn get(
        &self,
        location: impl LocationLike
    ) -> Result<&Self::Item, BoundsError> { ... }
fn view<T: LocComponent>(&self) -> View<Self, T> { ... }
fn rows(&self) -> RowsView<Self> { ... }
fn columns(&self) -> ColumnsView<Self> { ... }
unsafe fn single_view_unchecked<T: LocComponent>(
        &self,
        index: T
    ) -> SingleView<Self, T> { ... }
unsafe fn row_unchecked(&self, row: Row) -> RowView<Self> { ... }
unsafe fn column_unchecked(&self, column: Column) -> ColumnView<Self> { ... }
fn single_view<T: LocComponent>(
        &self,
        index: T
    ) -> Result<SingleView<Self, T>, RangeError<T>> { ... }
fn row(&self, row: impl Into<Row>) -> Result<RowView<Self>, RowRangeError> { ... }
fn column(
        &self,
        column: impl Into<Column>
    ) -> Result<ColumnView<Self>, ColumnRangeError> { ... } }

Base Reader trait for grids.

This trait provides the grid's cell type, Item, and a single, unsafe reader function, get_unchecked, which provides a reference to a cell at a location.

The Grid trait, which is automatically implemented for all [BaseGrid], provides a safe and comprehensive interface to a BaseGrid, which includes bounds checking based on GridBounds and many different view and iterator methods.

Trait for viewing the values in a grid

Grid provides a comprehensive interface for reading values in a grid. This interface includes bounds-checked getters, iterators, and views.

Associated Types

type Item

The item type stored in the grid

Loading content...

Required methods

unsafe fn get_unchecked(&self, location: &Location) -> &Self::Item

Get a reference to a cell, without doing bounds checking. Implementors of this method are allowed to assume that bounds checking has already been performed on the location, which means that implementors are allowed to do their own unsafe get operations on the underlying storage, where relevant / possible.

Loading content...

Provided methods

fn get(&self, location: impl LocationLike) -> Result<&Self::Item, BoundsError>

Get a reference to a cell in a grid. Returns an error if the location is out of bounds with the specific boundary violation.

fn view<T: LocComponent>(&self) -> View<Self, T>

fn rows(&self) -> RowsView<Self>

Get a view of a grid's rows. See [View] for details.

fn columns(&self) -> ColumnsView<Self>

Get a view of a grid's columns. See [View] for details.

unsafe fn single_view_unchecked<T: LocComponent>(
    &self,
    index: T
) -> SingleView<Self, T>

Get a view of a single row or column in a grid, without bounds checking that row or column index.

unsafe fn row_unchecked(&self, row: Row) -> RowView<Self>

Get a view of a single row in a grid, without bounds checking that row's index. Because this method is unsafe, we require the type safety of a Row (rather than Into) as an extra sanity check.

unsafe fn column_unchecked(&self, column: Column) -> ColumnView<Self>

Get a view of a single column in a grid, without bounds checking that column's index. Because this method is unsafe, we require the type safety of a Column (rather than Into) as an extra sanity check.

fn single_view<T: LocComponent>(
    &self,
    index: T
) -> Result<SingleView<Self, T>, RangeError<T>>

Get a view of a single row or column in a grid. Returns an error if the index of the row or column is out of bounds for the grid.

fn row(&self, row: impl Into<Row>) -> Result<RowView<Self>, RowRangeError>

Get a view of a single row in a grid. Returns an error if the index of the row is out of bounds for the grid.

fn column(
    &self,
    column: impl Into<Column>
) -> Result<ColumnView<Self>, ColumnRangeError>

Get a view of a single column in a grid. Returns an error if the index of the column is out of bounds for the grid.

Loading content...

Implementations on Foreign Types

impl<'_, G: Grid> Grid for &'_ G[src]

type Item = G::Item

impl<'_, G: Grid> Grid for &'_ mut G[src]

type Item = G::Item

Loading content...

Implementors

Loading content...