[][src]Struct bitboard_xo::BoardIter

pub struct BoardIter { /* fields omitted */ }

Immutable iterator through XOBoard

Construction

This struct can't be construct directly but can construct with XO::iter or XOBoard::iter

Iteration

Will Iterate starting from top-left cell and continue in book reading direction.

(iteration order from 0 -> 8)

| 0 | 1 | 2 |
| 3 | 4 | 5 |
| 6 | 7 | 8 |

Each iteration, yield

Examples

use bitboard_xo::{XO, XOPos, XOGameError, XOBoard, XOTokenWinState};
use bitboard_xo::XOToken::*;
use bitboard_xo::BoardIter;

/* create game with this board configuration:
X X O
. . .
. . .
*/
let board = XOBoard::from_maybe_token_array([
    Some(X), Some(X), Some(O),
    None   , None   , None   ,
    None   , None   , None   ,
]);

// note that XO also has the same method signature
let iter = board.iter();
assert!(iter.eq(
    [Some(X), Some(X), Some(O), None, None, None, None, None, None].iter().copied()
));

Notes

  • Since XO and XOBoard are copy type, this struct doesn't store mutable reference but store a copy XOBoard. so modifying the original XOBoard while iterating with this struct is both possible and safe (but might be unexpected)

Trait Implementations

impl Iterator for BoardIter[src]

type Item = Option<XOToken>

The type of the elements being iterated over.

Auto Trait Implementations

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.