[][src]Struct sweeper::iter::ColumnIter

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

Iterates over a single field column.

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

Usage

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

Methods

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

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

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

Panics

Panics if the specified row is out of range.

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

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

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

Returns the tile at the specified row.

Used as a convenience function, allowing you to write field.column(x).row(y) 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 ColumnIter<'f>[src]

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

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

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

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

type Output = Tile

The returned type after indexing.

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

Returns the tile at the specified row.

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

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

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

type Item = Tile

The type of the elements being iterated over.

Auto Trait Implementations

impl<'f> RefUnwindSafe for ColumnIter<'f>

impl<'f> Send for ColumnIter<'f>

impl<'f> Sync for ColumnIter<'f>

impl<'f> Unpin for ColumnIter<'f>

impl<'f> UnwindSafe for ColumnIter<'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>,