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>

source

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.

source

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.

source

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.

source

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.

source

pub fn range(&self) -> LocationRange<T>

Get the specific locations associated with this view.

source

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

source

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.

source

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.

source§

impl<'a, G: Grid + ?Sized> SingleView<'a, G, Row>

source

pub fn column( &self, column: impl Into<Column> ) -> Result<&'a G::Item, ColumnRangeError>

Get a reference to the cell in a specific column of this view’s row.

source§

impl<'a, G: Grid + ?Sized> SingleView<'a, G, Column>

source

pub fn row(&self, row: impl Into<Row>) -> Result<&'a G::Item, RowRangeError>

Get a reference to the cell in a specific row of this view’s column.

Trait Implementations§

source§

impl<'a, G: Grid + ?Sized, T: LocComponent> Clone for SingleView<'a, G, T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a, G: Debug + Grid + ?Sized, T: Debug + LocComponent> Debug for SingleView<'a, G, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, G: Grid + ?Sized, T: LocComponent> Index<<T as Component>::Converse> for SingleView<'a, G, T>

§

type Output = <G as Grid>::Item

The returned type after indexing.
source§

fn index(&self, idx: T::Converse) -> &G::Item

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<'a, G: ?Sized, T> RefUnwindSafe for SingleView<'a, G, T>

§

impl<'a, G: ?Sized, T> Send for SingleView<'a, G, T>
where G: Sync, T: Send,

§

impl<'a, G: ?Sized, T> Sync for SingleView<'a, G, T>
where G: Sync, T: Sync,

§

impl<'a, G: ?Sized, T> Unpin for SingleView<'a, G, T>
where T: Unpin,

§

impl<'a, G: ?Sized, T> UnwindSafe for SingleView<'a, G, T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.