[][src]Struct sweeper::iter::RowIter

pub struct RowIter<'f> { /* fields omitted */ }

Iterates over a single field row.

Can also be indexed to pull arbitrary tiles from the row, regardless of the iterator state.

Usage

let mut field = Field::empty( // Create a field to work with
    NonZeroUsize::new(9).unwrap(),
    NonZeroUsize::new(4).unwrap()
);
field[(8, 3)] = Tile::Mine(Flag::NotFlagged); // Place a mine (remember that indicies start from 0)
let mut rowiter = field.row(3); // Create an iterator over the fourth row
let mine_tile = rowiter.nth(8) // Find the nineth element in the row
    .unwrap(); // Get rid of the Option wrap
assert_eq!(mine_tile, Tile::Mine(Flag::NotFlagged)); // It's a mine

Methods

impl<'f> RowIter<'f>[src]

pub fn new(field: &'f Field, row: usize) -> Self[src]

Creates an iterator over the specified row of the specified field.

pub fn get(&self, column: usize) -> Option<Tile>[src]

Returns the tile at the specified column, or None if such a column doesn't exist. The row for which the iterator was created is used.

pub fn column(&self, column: usize) -> Tile[src]

Returns the tile at the specified column.

Used as a convenience function, allowing you to write field.row(y).column(x) to find specific tiles.

pub fn field(&self) -> &'f Field[src]

Returns the field which the iterator iterates over.

Trait Implementations

impl<'f> Clone for RowIter<'f>[src]

impl<'f> DoubleEndedIterator for RowIter<'f>[src]

impl<'f> ExactSizeIterator for RowIter<'f>[src]

fn len(&self) -> usize[src]

Returns the remaining amount of tiles to iterate upon.

impl<'_> FusedIterator for RowIter<'_>[src]

impl<'_> Index<usize> for RowIter<'_>[src]

type Output = Tile

The returned type after indexing.

fn index(&self, column: usize) -> &Tile[src]

Returns the tile at the specified column.

Used as a convenience function, allowing you to write field.row(y)[x] to find specific tiles.

This differs from .column() in the return type: this one returns a reference while .column() returns the tile by-value.

impl<'f> Iterator for RowIter<'f>[src]

type Item = Tile

The type of the elements being iterated over.

fn size_hint(&self) -> (usize, Option<usize>)[src]

Returns the remaining amount of tiles to iterate upon.

See len from the ExactSizedIterator trait.

Auto Trait Implementations

impl<'f> RefUnwindSafe for RowIter<'f>

impl<'f> Send for RowIter<'f>

impl<'f> Sync for RowIter<'f>

impl<'f> Unpin for RowIter<'f>

impl<'f> UnwindSafe for RowIter<'f>

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<I> IteratorRandom for I where
    I: Iterator
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,