[][src]Struct bitboard_xo::xo_pos::XOPos

pub struct XOPos { /* fields omitted */ }

Position in xo-grid

Methods

impl XOPos[src]

pub fn index(index: u32) -> Result<Self, XOPosError>[src]

Create XOPos from index, starting 0 at top left corner and counting up in book reading direction (see grid below)

Index grid:

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

Error

If invalid index is passed in (index >= 9), the error variant XOPosError::InvalidXOIndex will be returned

pub fn row_col(row: u32, col: u32) -> Result<Self, XOPosError>[src]

Create XOPos from (row, column) position.

(row, column) grid:

| 0,0 | 0,1 | 0,2 |
| 1,0 | 1,1 | 1,2 |
| 2,0 | 2,1 | 2,2 |

Error

If invalid row (row >= 3) or column (column >= 3) is passed in, the error variant XOPosError::InvalidXORow or XOPosError::InvalidXOCol will be returned correspondingly

pub fn col_row(col: u32, row: u32) -> Result<Self, XOPosError>[src]

Create XOPos from (column, row) position

(column, row) grid:

| 0,0 | 1,0 | 2,0 |
| 0,1 | 1,1 | 2,1 |
| 0,2 | 1,2 | 2,2 |

Error

If invalid row (row >= 3) or column (column >= 3) is passed in, the error variant XOPosError::InvalidXORow or XOPosError::InvalidXOCol will be returned correspondingly

pub fn as_index(self) -> u32[src]

Retrieve index inside this XOPos, guaranteed to be one of 0,1,2,3,4,5,6,7,8

Index grid:

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

Trait Implementations

impl Clone for XOPos[src]

impl Copy for XOPos[src]

impl Debug for XOPos[src]

impl TryFrom<u32> for XOPos[src]

type Error = XOPosError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for XOPos

impl Send for XOPos

impl Sync for XOPos

impl Unpin for XOPos

impl UnwindSafe for XOPos

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<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.