Struct gridly::grid::View

source ·
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>

source

pub fn len(&self) -> T::Distance

Get the length of this view; that is, the number of Rows or Columns

source

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.

source

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.

source

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

Get a range over all the row or column indexes of this view.

source

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.

source§

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

source

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

source§

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

source

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

Trait Implementations§

source§

impl<'a, G: Grid + ?Sized, T: LocComponent> Clone for View<'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 View<'a, G, T>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<'a, G: ?Sized, T> UnwindSafe for View<'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.