[][src]Struct sweeper::iter::FieldColumnsIter

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

An iterator over the columns of a field.

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 column_with_mine: Option<usize> = None; // Keep track of our findings using an Option
for (x, mut column) in field.columns().enumerate() { // In each column...
    if column.find(|t| t.is_mine()).is_some() { // If the column contains a mine...
        column_with_mine = Some(x); //...take the column number out of the loop.
    }
}
assert_eq!(column_with_mine, Some(8)); // We indeed have found a mine in the 9th column.

Methods

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

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

Returns an iterator over the specified field's columns.

Trait Implementations

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

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

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

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

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

type Item = ColumnIter<'f>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'f> RefUnwindSafe for FieldColumnsIter<'f>

impl<'f> Send for FieldColumnsIter<'f>

impl<'f> Sync for FieldColumnsIter<'f>

impl<'f> Unpin for FieldColumnsIter<'f>

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