pub struct View<'a, G: Grid + ?Sized, T: LocComponent> { /* private fields */ }
Expand description
A view of the rows or columns in a grid.
This struct provides a row- or column-major view of a grid. For instance,
a View<MyGrid, Row>
is a view of all of the rows in MyGrid
. The view
can be indexed over its type (for instance, a View<G, Row>
can be
indexed by Row
). It can also be iterated, where each iteration step
produces a SingleView
, which is a view of a single row or column (that
single view can itself be iterated to get all the cells).
Implementations§
source§impl<'a, G: Grid + ?Sized, T: LocComponent> View<'a, G, T>
impl<'a, G: Grid + ?Sized, T: LocComponent> View<'a, G, T>
sourcepub fn len(&self) -> T::Distance
pub fn len(&self) -> T::Distance
Get the length of this view; that is, the number of Rows or Columns
sourcepub unsafe fn get_unchecked(&self, index: T) -> SingleView<'a, G, T>
pub unsafe fn get_unchecked(&self, index: T) -> SingleView<'a, G, T>
Get a view of a single row or column of the grid, without bounds checking the index.
Safety
Callers must ensure that the index has been bounds-checked before calling this method.
sourcepub fn get(&self, index: T) -> Result<SingleView<'a, G, T>, RangeError<T>>
pub fn get(&self, index: T) -> Result<SingleView<'a, G, T>, RangeError<T>>
Get a view of a single row or column of the grid. Returns a range error if the index is out of range.
sourcepub fn range(&self) -> ComponentRange<T> ⓘ
pub fn range(&self) -> ComponentRange<T> ⓘ
Get a range over all the row or column indexes of this view.
sourcepub fn iter(
&self
) -> impl Iterator<Item = SingleView<'a, G, T>> + DoubleEndedIterator + FusedIterator + ExactSizeIterator + Debug + Clone
pub fn iter( &self ) -> impl Iterator<Item = SingleView<'a, G, T>> + DoubleEndedIterator + FusedIterator + ExactSizeIterator + Debug + Clone
Create an iterator over the rows or columns of the grid. Each iterated
element is a SingleView
, which is a view over a single row or column
of the grid.