Struct pleco::core::sq::SQ [−][src]
pub struct SQ(pub u8);
Represents a singular square of a chessboard.
Methods
impl SQ
[src]
impl SQ
pub const NONE: SQ
NONE: SQ = NO_SQ
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]
pub fn to_string(self) -> String
Returns the UCI String representation of a SQ
.
pub const fn is_okay(self) -> bool
[src]
pub const fn is_okay(self) -> bool
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]
pub fn distance(self, sq_other: SQ) -> u8
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 BitBoardpub fn to_bb(self) -> BitBoard
[src]
pub fn to_bb(self) -> BitBoard
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]
pub fn rank(self) -> Rank
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 BitBoardpub fn rank_bb(self) -> BitBoard
[src]
pub fn rank_bb(self) -> BitBoard
Returns the BitBoard
representation of a Rank
that a SQ
lies on.
pub const fn rank_idx_of_sq(self) -> u8
[src]
pub const fn rank_idx_of_sq(self) -> u8
Returns the rank index (number) of a SQ
.
pub fn file(self) -> File
[src]
pub fn file(self) -> File
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 BitBoardpub fn file_bb(self) -> BitBoard
[src]
pub fn file_bb(self) -> BitBoard
Returns the BitBoard
representation of a File
that a SQ
lies on.
pub const fn file_idx_of_sq(self) -> u8
[src]
pub const fn file_idx_of_sq(self) -> u8
Returns the file index (number) of a SQ
.
pub fn castle_rights_mask(self) -> u8
[src]
pub fn castle_rights_mask(self) -> u8
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]
pub fn make(file: File, rank: Rank) -> SQ
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]
pub fn on_dark_square(self) -> bool
Returns if the SQ
is a dark square.
pub fn on_light_square(self) -> bool
[src]
pub fn on_light_square(self) -> bool
Returns if the SQ
is a dark square.
pub fn square_color_index(self) -> usize
[src]
pub fn square_color_index(self) -> usize
Returns the player index of the color of the square.
pub fn flip(self) -> SQ
[src]
pub fn flip(self) -> SQ
Flips the square's rank, so SQ::A1
-> SQ::A8
.
pub fn opposite_colors(self, other: SQ) -> bool
[src]
pub fn opposite_colors(self, other: SQ) -> bool
Determines if two squares are on opposite colors.
Trait Implementations
impl Copy for SQ
[src]
impl Copy for SQ
impl Clone for SQ
[src]
impl Clone for SQ
fn clone(&self) -> SQ
[src]
fn clone(&self) -> SQ
Returns 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 Default for SQ
[src]
impl Default for SQ
impl Hash for SQ
[src]
impl Hash for SQ
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
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 PartialEq for SQ
[src]
impl PartialEq for SQ
fn eq(&self, other: &SQ) -> bool
[src]
fn eq(&self, other: &SQ) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &SQ) -> bool
[src]
fn ne(&self, other: &SQ) -> bool
This method tests for !=
.
impl PartialOrd for SQ
[src]
impl PartialOrd for SQ
fn partial_cmp(&self, other: &SQ) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &SQ) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &SQ) -> bool
[src]
fn lt(&self, other: &SQ) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &SQ) -> bool
[src]
fn le(&self, other: &SQ) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &SQ) -> bool
[src]
fn gt(&self, other: &SQ) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &SQ) -> bool
[src]
fn ge(&self, other: &SQ) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Eq for SQ
[src]
impl Eq for SQ
impl Debug for SQ
[src]
impl Debug for SQ
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl From<u8> for SQ
[src]
impl From<u8> for SQ
impl From<SQ> for u8
[src]
impl From<SQ> for u8
impl Rem for SQ
[src]
impl Rem for SQ
type Output = SQ
The resulting type after applying the %
operator.
fn rem(self, rhs: SQ) -> SQ
[src]
fn rem(self, rhs: SQ) -> SQ
Performs the %
operation.
impl RemAssign for SQ
[src]
impl RemAssign for SQ
fn rem_assign(&mut self, rhs: SQ)
[src]
fn rem_assign(&mut self, rhs: SQ)
Performs the %=
operation.
impl Rem<u8> for SQ
[src]
impl Rem<u8> for SQ
type Output = SQ
The resulting type after applying the %
operator.
fn rem(self, rhs: u8) -> SQ
[src]
fn rem(self, rhs: u8) -> SQ
Performs the %
operation.
impl RemAssign<u8> for SQ
[src]
impl RemAssign<u8> for SQ
fn rem_assign(&mut self, rhs: u8)
[src]
fn rem_assign(&mut self, rhs: u8)
Performs the %=
operation.
impl BitOr for SQ
[src]
impl BitOr for SQ
type Output = SQ
The resulting type after applying the |
operator.
fn bitor(self, rhs: SQ) -> SQ
[src]
fn bitor(self, rhs: SQ) -> SQ
Performs the |
operation.
impl BitOrAssign for SQ
[src]
impl BitOrAssign for SQ
fn bitor_assign(&mut self, rhs: SQ)
[src]
fn bitor_assign(&mut self, rhs: SQ)
Performs the |=
operation.
impl BitOr<u8> for SQ
[src]
impl BitOr<u8> for SQ
type Output = SQ
The resulting type after applying the |
operator.
fn bitor(self, rhs: u8) -> SQ
[src]
fn bitor(self, rhs: u8) -> SQ
Performs the |
operation.
impl BitOrAssign<u8> for SQ
[src]
impl BitOrAssign<u8> for SQ
fn bitor_assign(&mut self, rhs: u8)
[src]
fn bitor_assign(&mut self, rhs: u8)
Performs the |=
operation.
impl BitAnd for SQ
[src]
impl BitAnd for SQ
type Output = SQ
The resulting type after applying the &
operator.
fn bitand(self, rhs: SQ) -> SQ
[src]
fn bitand(self, rhs: SQ) -> SQ
Performs the &
operation.
impl BitAndAssign for SQ
[src]
impl BitAndAssign for SQ
fn bitand_assign(&mut self, rhs: SQ)
[src]
fn bitand_assign(&mut self, rhs: SQ)
Performs the &=
operation.
impl BitAnd<u8> for SQ
[src]
impl BitAnd<u8> for SQ
type Output = SQ
The resulting type after applying the &
operator.
fn bitand(self, rhs: u8) -> SQ
[src]
fn bitand(self, rhs: u8) -> SQ
Performs the &
operation.
impl BitAndAssign<u8> for SQ
[src]
impl BitAndAssign<u8> for SQ
fn bitand_assign(&mut self, rhs: u8)
[src]
fn bitand_assign(&mut self, rhs: u8)
Performs the &=
operation.
impl BitXor for SQ
[src]
impl BitXor for SQ
type Output = SQ
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: SQ) -> SQ
[src]
fn bitxor(self, rhs: SQ) -> SQ
Performs the ^
operation.
impl BitXorAssign for SQ
[src]
impl BitXorAssign for SQ
fn bitxor_assign(&mut self, rhs: SQ)
[src]
fn bitxor_assign(&mut self, rhs: SQ)
Performs the ^=
operation.
impl BitXor<u8> for SQ
[src]
impl BitXor<u8> for SQ
type Output = SQ
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: u8) -> SQ
[src]
fn bitxor(self, rhs: u8) -> SQ
Performs the ^
operation.
impl BitXorAssign<u8> for SQ
[src]
impl BitXorAssign<u8> for SQ
fn bitxor_assign(&mut self, rhs: u8)
[src]
fn bitxor_assign(&mut self, rhs: u8)
Performs the ^=
operation.
impl Add for SQ
[src]
impl Add for SQ
type Output = SQ
The resulting type after applying the +
operator.
fn add(self, rhs: SQ) -> SQ
[src]
fn add(self, rhs: SQ) -> SQ
Performs the +
operation.
impl AddAssign for SQ
[src]
impl AddAssign for SQ
fn add_assign(&mut self, rhs: SQ)
[src]
fn add_assign(&mut self, rhs: SQ)
Performs the +=
operation.
impl Add<u8> for SQ
[src]
impl Add<u8> for SQ
type Output = SQ
The resulting type after applying the +
operator.
fn add(self, rhs: u8) -> SQ
[src]
fn add(self, rhs: u8) -> SQ
Performs the +
operation.
impl AddAssign<u8> for SQ
[src]
impl AddAssign<u8> for SQ
fn add_assign(&mut self, rhs: u8)
[src]
fn add_assign(&mut self, rhs: u8)
Performs the +=
operation.
impl Div for SQ
[src]
impl Div for SQ
type Output = SQ
The resulting type after applying the /
operator.
fn div(self, rhs: SQ) -> SQ
[src]
fn div(self, rhs: SQ) -> SQ
Performs the /
operation.
impl DivAssign for SQ
[src]
impl DivAssign for SQ
fn div_assign(&mut self, rhs: SQ)
[src]
fn div_assign(&mut self, rhs: SQ)
Performs the /=
operation.
impl Div<u8> for SQ
[src]
impl Div<u8> for SQ
type Output = SQ
The resulting type after applying the /
operator.
fn div(self, rhs: u8) -> SQ
[src]
fn div(self, rhs: u8) -> SQ
Performs the /
operation.
impl DivAssign<u8> for SQ
[src]
impl DivAssign<u8> for SQ
fn div_assign(&mut self, rhs: u8)
[src]
fn div_assign(&mut self, rhs: u8)
Performs the /=
operation.
impl Mul for SQ
[src]
impl Mul for SQ
type Output = SQ
The resulting type after applying the *
operator.
fn mul(self, rhs: SQ) -> SQ
[src]
fn mul(self, rhs: SQ) -> SQ
Performs the *
operation.
impl MulAssign for SQ
[src]
impl MulAssign for SQ
fn mul_assign(&mut self, rhs: SQ)
[src]
fn mul_assign(&mut self, rhs: SQ)
Performs the *=
operation.
impl Mul<u8> for SQ
[src]
impl Mul<u8> for SQ
type Output = SQ
The resulting type after applying the *
operator.
fn mul(self, rhs: u8) -> SQ
[src]
fn mul(self, rhs: u8) -> SQ
Performs the *
operation.
impl MulAssign<u8> for SQ
[src]
impl MulAssign<u8> for SQ
fn mul_assign(&mut self, rhs: u8)
[src]
fn mul_assign(&mut self, rhs: u8)
Performs the *=
operation.
impl Sub for SQ
[src]
impl Sub for SQ
type Output = SQ
The resulting type after applying the -
operator.
fn sub(self, rhs: SQ) -> SQ
[src]
fn sub(self, rhs: SQ) -> SQ
Performs the -
operation.
impl SubAssign for SQ
[src]
impl SubAssign for SQ
fn sub_assign(&mut self, rhs: SQ)
[src]
fn sub_assign(&mut self, rhs: SQ)
Performs the -=
operation.
impl Sub<u8> for SQ
[src]
impl Sub<u8> for SQ
type Output = SQ
The resulting type after applying the -
operator.
fn sub(self, rhs: u8) -> SQ
[src]
fn sub(self, rhs: u8) -> SQ
Performs the -
operation.
impl SubAssign<u8> for SQ
[src]
impl SubAssign<u8> for SQ
fn sub_assign(&mut self, rhs: u8)
[src]
fn sub_assign(&mut self, rhs: u8)
Performs the -=
operation.
impl Shl<usize> for SQ
[src]
impl Shl<usize> for SQ
type Output = SQ
The resulting type after applying the <<
operator.
fn shl(self, rhs: usize) -> SQ
[src]
fn shl(self, rhs: usize) -> SQ
Performs the <<
operation.
impl ShlAssign<usize> for SQ
[src]
impl ShlAssign<usize> for SQ
fn shl_assign(&mut self, rhs: usize)
[src]
fn shl_assign(&mut self, rhs: usize)
Performs the <<=
operation.
impl Shr<usize> for SQ
[src]
impl Shr<usize> for SQ
type Output = SQ
The resulting type after applying the >>
operator.
fn shr(self, rhs: usize) -> SQ
[src]
fn shr(self, rhs: usize) -> SQ
Performs the >>
operation.
impl ShrAssign<usize> for SQ
[src]
impl ShrAssign<usize> for SQ
fn shr_assign(&mut self, rhs: usize)
[src]
fn shr_assign(&mut self, rhs: usize)
Performs the >>=
operation.
impl Not for SQ
[src]
impl Not for SQ
type Output = SQ
The resulting type after applying the !
operator.
fn not(self) -> SQ
[src]
fn not(self) -> SQ
Performs the unary !
operation.
impl Display for SQ
[src]
impl Display for SQ
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Shl<SQ> for BitBoard
[src]
impl Shl<SQ> for BitBoard