[][src]Struct ingrid::EnumerateCoordinate

pub struct EnumerateCoordinate<I> { /* fields omitted */ }

An iterator that yields the current coordinate

This structure is an iterator that yields the current coordinate and the element of the grid during iteration. It's created by the enumerate_coordinate() method on GridIterator.

Examples

Iterating over a grid with the element coordinates.

let grid = Grid::from_rows(vec![vec![1, 2],
                                vec![3, 4]]);

let mut iterator = grid.iterator().enumerate_coordinate();
assert_eq!(iterator.next(), Some((coord!(0, 0), &1)));
assert_eq!(iterator.next(), Some((coord!(1, 0), &2)));
assert_eq!(iterator.next(), Some((coord!(0, 1), &3)));
assert_eq!(iterator.next(), Some((coord!(1, 1), &4)));
assert_eq!(iterator.next(), None);

Iterating over rows and columns with their element coordinates.

let grid = Grid::from_rows(vec![vec![1, 2],
                                vec![3, 4]]);

let mut iterator = grid.row(0).iterator().enumerate_coordinate();
assert_eq!(iterator.next(), Some((coord!(0, 0), &1)));
assert_eq!(iterator.next(), Some((coord!(1, 0), &2)));
assert_eq!(iterator.next(), None);

let mut iterator = grid.column(1).iterator().enumerate_coordinate();
assert_eq!(iterator.next(), Some((coord!(1, 0), &2)));
assert_eq!(iterator.next(), Some((coord!(1, 1), &4)));
assert_eq!(iterator.next(), None);

Methods

impl<I: GridIterator> EnumerateCoordinate<I>[src]

Important traits for EnumerateCoordinate<I>
pub fn new(iterator: I) -> EnumerateCoordinate<I>[src]

Trait Implementations

impl<I: GridIterator> Iterator for EnumerateCoordinate<I>[src]

type Item = (Coordinate, <I as Iterator>::Item)

The type of the elements being iterated over.

Auto Trait Implementations

impl<I> RefUnwindSafe for EnumerateCoordinate<I> where
    I: RefUnwindSafe

impl<I> Send for EnumerateCoordinate<I> where
    I: Send

impl<I> Sync for EnumerateCoordinate<I> where
    I: Sync

impl<I> Unpin for EnumerateCoordinate<I> where
    I: Unpin

impl<I> UnwindSafe for EnumerateCoordinate<I> where
    I: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.