Struct gridly::grid::SingleView
source · pub struct SingleView<'a, G: Grid + ?Sized, T: LocComponent> { /* private fields */ }
Expand description
View of a single Row or Column of a grid.
A SingleView
provides a view over a single row or column of a grid, based
on its generic parameter. For instance, a SingleView<’a, G, Row> is a view
over a single row of a grid.
A SingleView
can be indexed; for instance, a RowView
can be indexed
with a Column
to a get a specific cell.
Implementations§
source§impl<'a, G: Grid + ?Sized, T: LocComponent> SingleView<'a, G, T>
impl<'a, G: Grid + ?Sized, T: LocComponent> SingleView<'a, G, T>
sourcepub fn len(&self) -> <T::Converse as LocComponent>::Distance
pub fn len(&self) -> <T::Converse as LocComponent>::Distance
Get the length of this view. For example, for a
SingleView<'a, G, Row>
, get the number of columns.
sourcepub fn index(&self) -> T
pub fn index(&self) -> T
Get the index of the Row or Column that this view represents. This index
is safely guaranteed to have been bounds checked when the SingleView
was constructed.
sourcepub unsafe fn get_unchecked(&self, cross: T::Converse) -> &'a G::Item
pub unsafe fn get_unchecked(&self, cross: T::Converse) -> &'a G::Item
Get a particular cell in the row or column by an index, without bounds checking the index.
Safety
Callers must ensure that the index has been bounds-checked before calling this method.
sourcepub fn get(
&self,
cross: T::Converse
) -> Result<&'a G::Item, RangeError<T::Converse>>
pub fn get( &self, cross: T::Converse ) -> Result<&'a G::Item, RangeError<T::Converse>>
Get a particular cell in the row or column, or return an error if the index is out of bounds.
sourcepub fn range(&self) -> LocationRange<T> ⓘ
pub fn range(&self) -> LocationRange<T> ⓘ
Get the specific locations associated with this view.
sourcepub fn iter(
&self
) -> impl Iterator<Item = &'a G::Item> + DoubleEndedIterator + FusedIterator + ExactSizeIterator + Debug + Clone
pub fn iter( &self ) -> impl Iterator<Item = &'a G::Item> + DoubleEndedIterator + FusedIterator + ExactSizeIterator + Debug + Clone
Get an iterator over the cells in this row or column
sourcepub fn iter_with_locations(
&self
) -> impl Iterator<Item = (Location, &'a G::Item)> + DoubleEndedIterator + FusedIterator + ExactSizeIterator + Debug + Clone
pub fn iter_with_locations( &self ) -> impl Iterator<Item = (Location, &'a G::Item)> + DoubleEndedIterator + FusedIterator + ExactSizeIterator + Debug + Clone
Get an iterator over (Location, &Item)
pairs for this row or column.
sourcepub fn iter_with_indices(
&self
) -> impl Iterator<Item = (T::Converse, &'a G::Item)> + DoubleEndedIterator + FusedIterator + ExactSizeIterator + Debug + Clone
pub fn iter_with_indices( &self ) -> impl Iterator<Item = (T::Converse, &'a G::Item)> + DoubleEndedIterator + FusedIterator + ExactSizeIterator + Debug + Clone
Get an iterator over (Index, &Item)
pairs for this column. For instance,
for a RowView
, this iterates over (Column, &Item)
pairs.