Enum pgn_reader::Square [−][src]
#[repr(i8)]pub enum Square { A1, B1, C1, D1, E1, F1, G1, H1, A2, B2, C2, D2, E2, F2, G2, H2, A3, B3, C3, D3, E3, F3, G3, H3, A4, B4, C4, D4, E4, F4, G4, H4, A5, B5, C5, D5, E5, F5, G5, H5, A6, B6, C6, D6, E6, F6, G6, H6, A7, B7, C7, D7, E7, F7, G7, H7, A8, B8, C8, D8, E8, F8, G8, H8, }
A square index.
Variants
A1B1C1D1E1F1G1H1A2B2C2D2E2F2G2H2A3B3C3D3E3F3G3H3A4B4C4D4E4F4G4H4A5B5C5D5E5F5G5H5A6B6C6D6E6F6G6H6A7B7C7D7E7F7G7H7A8B8C8D8E8F8G8H8
Methods
impl Square[src]
impl Squarepub fn new(index: i8) -> Square[src]
pub fn new(index: i8) -> Squarepub fn from_index(index: i8) -> Option<Square>[src]
pub fn from_index(index: i8) -> Option<Square>Tries to get a Square from an integer index in the range 0..=63.
pub unsafe fn from_index_unchecked(index: i8) -> Square[src]
pub unsafe fn from_index_unchecked(index: i8) -> SquareGets a Square from an integer index.
Unsafety
It is the callers responsibility to ensure it is in the range 0..=63.
pub fn from_coords(file: File, rank: Rank) -> Square[src]
pub fn from_coords(file: File, rank: Rank) -> SquareTries to get a square from file and rank.
pub fn from_ascii(s: &[u8]) -> Result<Square, InvalidSquareName>[src]
pub fn from_ascii(s: &[u8]) -> Result<Square, InvalidSquareName>Parses a square name.
Errors
Returns InvalidSquareName if the input is not a valid square name
in lowercase ASCII characters.
Example
use shakmaty::Square; let sq = Square::from_ascii(b"a5")?; assert_eq!(sq, Square::A5);
pub fn file(self) -> File[src]
pub fn file(self) -> Filepub fn rank(self) -> Rank[src]
pub fn rank(self) -> Rankpub fn offset(self, delta: i8) -> Option<Square>[src]
pub fn offset(self, delta: i8) -> Option<Square>pub fn flip_horizontal(self) -> Square[src]
pub fn flip_horizontal(self) -> SquareFlip the square horizontally.
use shakmaty::Square; assert_eq!(Square::H1.flip_horizontal(), Square::A1); assert_eq!(Square::D3.flip_horizontal(), Square::E3);
pub fn flip_vertical(self) -> Square[src]
pub fn flip_vertical(self) -> SquareFlip the square vertically.
use shakmaty::Square; assert_eq!(Square::A8.flip_vertical(), Square::A1); assert_eq!(Square::D3.flip_vertical(), Square::D6);
pub fn flip_diagonal(self) -> Square[src]
pub fn flip_diagonal(self) -> SquareFlip at the a1-h8 diagonal by swapping file and rank.
use shakmaty::Square; assert_eq!(Square::A1.flip_diagonal(), Square::A1); assert_eq!(Square::A3.flip_diagonal(), Square::C1);
pub fn is_light(self) -> bool[src]
pub fn is_light(self) -> boolTests is the square is a light square.
use shakmaty::Square; assert!(Square::D1.is_light()); assert!(!Square::D8.is_light());
pub fn is_dark(self) -> bool[src]
pub fn is_dark(self) -> boolTests is the square is a dark square.
use shakmaty::Square; assert!(Square::E1.is_dark()); assert!(!Square::E8.is_dark());
pub fn distance(self, other: Square) -> i8[src]
pub fn distance(self, other: Square) -> i8The distance between the two squares, i.e. the number of king steps to get from one square to the other.
use shakmaty::Square; assert_eq!(Square::A2.distance(Square::B5), 3);
pub fn combine(self, rank: Square) -> Square[src]
pub fn combine(self, rank: Square) -> SquareCombines two squares, taking the file from the first and the rank from the second.
use shakmaty::Square; assert_eq!(Square::D3.combine(Square::F5), Square::D5);
Trait Implementations
impl Extend<Square> for Bitboard[src]
impl Extend<Square> for Bitboardfn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = Square>, [src]
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = Square>, Extends a collection with the contents of an iterator. Read more
impl PartialOrd<Square> for Square[src]
impl PartialOrd<Square> for Squarefn partial_cmp(&self, other: &Square) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &Square) -> Option<Ordering>This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
fn lt(&self, other: &Rhs) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0[src]
fn le(&self, other: &Rhs) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
fn gt(&self, other: &Rhs) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
fn ge(&self, other: &Rhs) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Hash for Square[src]
impl Hash for Squarefn hash<__H>(&self, state: &mut __H) where
__H: Hasher, [src]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher, Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, Feeds a slice of this type into the given [Hasher]. Read more
impl Sub<Square> for Square[src]
impl Sub<Square> for Squaretype Output = i8
The resulting type after applying the - operator.
fn sub(self, other: Square) -> i8[src]
fn sub(self, other: Square) -> i8Performs the - operation.
impl Clone for Square[src]
impl Clone for Squarefn clone(&self) -> Square[src]
fn clone(&self) -> SquareReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl FromStr for Square[src]
impl FromStr for Squaretype Err = InvalidSquareName
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Square, InvalidSquareName>[src]
fn from_str(s: &str) -> Result<Square, InvalidSquareName>Parses a string s to return a value of this type. Read more
impl Debug for Square[src]
impl Debug for Squarefn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>Formats the value using the given formatter. Read more
impl Ord for Square[src]
impl Ord for Squarefn cmp(&self, other: &Square) -> Ordering[src]
fn cmp(&self, other: &Square) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl From<Square> for i16[src]
impl From<Square> for i16impl From<Square> for Bitboard[src]
impl From<Square> for Bitboardimpl From<Square> for i8[src]
impl From<Square> for i8impl From<Square> for isize[src]
impl From<Square> for isizeimpl From<Square> for i32[src]
impl From<Square> for i32impl From<Square> for usize[src]
impl From<Square> for usizeimpl From<Square> for u64[src]
impl From<Square> for u64impl From<Square> for u128[src]
impl From<Square> for u128impl From<Square> for u8[src]
impl From<Square> for u8impl From<Square> for i128[src]
impl From<Square> for i128impl From<Square> for u16[src]
impl From<Square> for u16impl From<Square> for u32[src]
impl From<Square> for u32impl From<Square> for i64[src]
impl From<Square> for i64impl From<(File, Rank)> for Square[src]
impl From<(File, Rank)> for Squareimpl FromIterator<Square> for Bitboard[src]
impl FromIterator<Square> for Bitboardfn from_iter<T>(iter: T) -> Bitboard where
T: IntoIterator<Item = Square>, [src]
fn from_iter<T>(iter: T) -> Bitboard where
T: IntoIterator<Item = Square>, Creates a value from an iterator. Read more
impl Display for Square[src]
impl Display for Squarefn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>Formats the value using the given formatter. Read more
impl Copy for Square[src]
impl Copy for Squareimpl Eq for Square[src]
impl Eq for Squareimpl PartialEq<Square> for Square[src]
impl PartialEq<Square> for Square