[][src]Struct sweeper::iter::FieldRowsIter

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

An iterator over the rows of a field.

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

Methods

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

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

Returns an iterator over the specified field's rows.

Trait Implementations

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

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

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

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

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

type Item = RowIter<'f>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'f> RefUnwindSafe for FieldRowsIter<'f>

impl<'f> Send for FieldRowsIter<'f>

impl<'f> Sync for FieldRowsIter<'f>

impl<'f> Unpin for FieldRowsIter<'f>

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