[−][src]Struct bitboard_xo::xo_pos::XOPos
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.
fn try_from(value: u32) -> Result<Self, XOPosError>
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,