[][src]Struct pleco::core::sq::SQ

#[repr(transparent)]
pub struct SQ(pub u8);

Represents a singular square of a chessboard.

Methods

impl SQ[src]

pub const NONE: SQ[src]

A square that isn't on the board. Basically equivilant to Option<SQ> where the value is None.

pub fn to_string(self) -> String[src]

Returns the UCI String representation of a SQ.

pub const fn is_okay(self) -> bool[src]

Returns if a SQ is within the legal bounds of a square, which is inclusively between 0 - 63.

Examples

use pleco::SQ;
let sq_ok = SQ(5);
let no_sq = SQ(64);

assert!(sq_ok.is_okay());
assert!(!no_sq.is_okay());

pub fn distance(self, sq_other: SQ) -> u8[src]

Returns distance between this square and another square. Distance is not in algebraic difference, but in squares away.

Examples

use pleco::SQ;

let a1 = SQ::A1;
let b2 = SQ::B2;
let b3 = SQ::B3;

assert_eq!(a1.distance(a1), 0);
assert_eq!(a1.distance(b2), 1);
assert_eq!(a1.distance(b3), 2);

Important traits for BitBoard
pub fn to_bb(self) -> BitBoard[src]

Converts a SQ to it's BitBoard equivalent. The resulting BitBoard will have exactly 1 bit set at the index where the square is location on the chessboard.

pub fn rank(self) -> Rank[src]

Returns the Rank that a SQ lies on.

Examples

use pleco::{SQ,Rank};

let sq_f2 = SQ::F2;
assert_eq!(sq_f2.rank(), Rank::R2);

Important traits for BitBoard
pub fn rank_bb(self) -> BitBoard[src]

Returns the BitBoard representation of a Rank that a SQ lies on.

pub const fn rank_idx_of_sq(self) -> u8[src]

Returns the rank index (number) of a SQ.

pub fn file(self) -> File[src]

Returns the File that a SQ lies on.

Examples

use pleco::{SQ,File};

let sq_f2 = SQ::F2;
assert_eq!(sq_f2.file(), File::F);

Important traits for BitBoard
pub fn file_bb(self) -> BitBoard[src]

Returns the BitBoard representation of a File that a SQ lies on.

pub const fn file_idx_of_sq(self) -> u8[src]

Returns the file index (number) of a SQ.

pub fn castle_rights_mask(self) -> u8[src]

Returns the castle rights mask for the given square. If the square does not have a castle rights mask, returns 0.

pub fn make(file: File, rank: Rank) -> SQ[src]

Creates a SQ from the designated File and Rank.

Examples

use pleco::{SQ,Rank,File};

let file_f = File::F;
let rank_2 = Rank::R2;
let sq_f2 = SQ::F2;

assert_eq!(sq_f2, SQ::make(file_f, rank_2));

pub fn on_dark_square(self) -> bool[src]

Returns if the SQ is a dark square.

pub fn on_light_square(self) -> bool[src]

Returns if the SQ is a dark square.

pub fn square_color_index(self) -> usize[src]

Returns the player index of the color of the square.

pub fn flip(self) -> SQ[src]

Flips the square's rank, so SQ::A1 -> SQ::A8.

pub fn opposite_colors(self, other: SQ) -> bool[src]

Determines if two squares are on opposite colors.

Trait Implementations

impl Eq for SQ[src]

impl Copy for SQ[src]

impl PartialOrd<SQ> for SQ[src]

impl Default for SQ[src]

impl PartialEq<SQ> for SQ[src]

impl From<u8> for SQ[src]

impl From<SQ> for u8[src]

impl Clone for SQ[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Display for SQ[src]

impl Debug for SQ[src]

impl Add<SQ> for SQ[src]

type Output = SQ

The resulting type after applying the + operator.

impl Add<u8> for SQ[src]

type Output = SQ

The resulting type after applying the + operator.

impl Sub<SQ> for SQ[src]

type Output = SQ

The resulting type after applying the - operator.

impl Sub<u8> for SQ[src]

type Output = SQ

The resulting type after applying the - operator.

impl Mul<SQ> for SQ[src]

type Output = SQ

The resulting type after applying the * operator.

impl Mul<u8> for SQ[src]

type Output = SQ

The resulting type after applying the * operator.

impl Div<SQ> for SQ[src]

type Output = SQ

The resulting type after applying the / operator.

impl Div<u8> for SQ[src]

type Output = SQ

The resulting type after applying the / operator.

impl Rem<SQ> for SQ[src]

type Output = SQ

The resulting type after applying the % operator.

impl Rem<u8> for SQ[src]

type Output = SQ

The resulting type after applying the % operator.

impl AddAssign<SQ> for SQ[src]

impl AddAssign<u8> for SQ[src]

impl SubAssign<SQ> for SQ[src]

impl SubAssign<u8> for SQ[src]

impl MulAssign<SQ> for SQ[src]

impl MulAssign<u8> for SQ[src]

impl DivAssign<SQ> for SQ[src]

impl DivAssign<u8> for SQ[src]

impl RemAssign<SQ> for SQ[src]

impl RemAssign<u8> for SQ[src]

impl Not for SQ[src]

type Output = SQ

The resulting type after applying the ! operator.

impl BitAnd<SQ> for SQ[src]

type Output = SQ

The resulting type after applying the & operator.

impl BitAnd<u8> for SQ[src]

type Output = SQ

The resulting type after applying the & operator.

impl BitOr<SQ> for SQ[src]

type Output = SQ

The resulting type after applying the | operator.

impl BitOr<u8> for SQ[src]

type Output = SQ

The resulting type after applying the | operator.

impl BitXor<SQ> for SQ[src]

type Output = SQ

The resulting type after applying the ^ operator.

impl BitXor<u8> for SQ[src]

type Output = SQ

The resulting type after applying the ^ operator.

impl Shl<usize> for SQ[src]

type Output = SQ

The resulting type after applying the << operator.

impl Shl<SQ> for BitBoard[src]

type Output = BitBoard

The resulting type after applying the << operator.

impl Shr<usize> for SQ[src]

type Output = SQ

The resulting type after applying the >> operator.

impl BitAndAssign<SQ> for SQ[src]

impl BitAndAssign<u8> for SQ[src]

impl BitOrAssign<SQ> for SQ[src]

impl BitOrAssign<u8> for SQ[src]

impl BitXorAssign<SQ> for SQ[src]

impl BitXorAssign<u8> for SQ[src]

impl ShlAssign<usize> for SQ[src]

impl ShrAssign<usize> for SQ[src]

impl Hash for SQ[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl Send for SQ

impl Sync for SQ

Blanket Implementations

impl<T, U> Into 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> From for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.