Struct pleco::board::castle_rights::Castling [−]
pub struct Castling { /* fields omitted */ }
Structure to help with recognizing the various possibilities of castling.
For internal use by the Board
only.
Keeps track of what sides are possible to castle from for each player.
Does not guarantee that the player containing a castling bit can castle at that time. Rather marks that castling is a possibility, e.g. a Castling struct containing a bit marking WHITE_Q means that neither the White King or Queen-side rook has moved since the game started.
Methods
impl Castling
impl Castling
pub const WHITE_K: Castling
WHITE_K: Castling = Castling{bits: C_WHITE_K_MASK,}
pub const WHITE_Q: Castling
WHITE_Q: Castling = Castling{bits: C_WHITE_Q_MASK,}
pub const BLACK_K: Castling
BLACK_K: Castling = Castling{bits: C_BLACK_K_MASK,}
pub const BLACK_Q: Castling
BLACK_Q: Castling = Castling{bits: C_BLACK_Q_MASK,}
pub const WHITE_ALL: Castling
WHITE_ALL: Castling = Castling{bits: <Self>::WHITE_K.bits | <Self>::WHITE_Q.bits,}
pub const BLACK_ALL: Castling
BLACK_ALL: Castling = Castling{bits: <Self>::BLACK_K.bits | <Self>::BLACK_Q.bits,}
pub fn empty() -> Castling
pub fn empty() -> Castling
Returns an empty set of flags.
pub fn all() -> Castling
pub fn all() -> Castling
Returns the set containing all flags.
pub fn bits(&self) -> u8
pub fn bits(&self) -> u8
Returns the raw value of the flags currently stored.
pub fn from_bits(bits: u8) -> Option<Castling>
pub fn from_bits(bits: u8) -> Option<Castling>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
pub fn from_bits_truncate(bits: u8) -> Castling
pub fn from_bits_truncate(bits: u8) -> Castling
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if no flags are currently stored.
pub fn is_all(&self) -> bool
pub fn is_all(&self) -> bool
Returns true
if all flags are currently set.
pub fn intersects(&self, other: Castling) -> bool
pub fn intersects(&self, other: Castling) -> bool
Returns true
if there are flags common to both self
and other
.
pub fn contains(&self, other: Castling) -> bool
pub fn contains(&self, other: Castling) -> bool
Returns true
all of the flags in other
are contained within self
.
pub fn insert(&mut self, other: Castling)
pub fn insert(&mut self, other: Castling)
Inserts the specified flags in-place.
pub fn remove(&mut self, other: Castling)
pub fn remove(&mut self, other: Castling)
Removes the specified flags in-place.
pub fn toggle(&mut self, other: Castling)
pub fn toggle(&mut self, other: Castling)
Toggles the specified flags in-place.
pub fn set(&mut self, other: Castling, value: bool)
pub fn set(&mut self, other: Castling, value: bool)
Inserts or removes the specified flags depending on the passed value.
impl Castling
[src]
impl Castling
pub fn remove_player_castling(&mut self, player: Player)
[src]
pub fn remove_player_castling(&mut self, player: Player)
Removes all castling possibility for a single player
pub fn remove_king_side_castling(&mut self, player: Player)
[src]
pub fn remove_king_side_castling(&mut self, player: Player)
Removes King-Side castling possibility for a single player
pub fn remove_queen_side_castling(&mut self, player: Player)
[src]
pub fn remove_queen_side_castling(&mut self, player: Player)
Removes Queen-Side castling possibility for a single player
pub fn castle_rights(&self, player: Player, side: CastleType) -> bool
[src]
pub fn castle_rights(&self, player: Player, side: CastleType) -> bool
Returns if a player can castle for a given side
pub fn player_can_castle(&self, player: Player) -> Castling
[src]
pub fn player_can_castle(&self, player: Player) -> Castling
pub fn no_castling(&self) -> bool
[src]
pub fn no_castling(&self) -> bool
Returns if both players have lost their ability to castle
pub fn update_castling(&mut self, to: SQ, from: SQ) -> u8
[src]
pub fn update_castling(&mut self, to: SQ, from: SQ) -> u8
pub fn add_castling_char(&mut self, c: char)
[src]
pub fn add_castling_char(&mut self, c: char)
Adds the Right to castle based on an char
.
`K` -> Add White King-side Castling bit.
`Q` -> Add White Queen-side Castling bit.
`k` -> Add Black King-side Castling bit.
`q` -> Add Black Queen-side Castling bit.
`-` -> Do nothing.
Panics
Panics of the char is not K
, Q
, k
, q
, or -
.
pub fn pretty_string(&self) -> String
[src]
pub fn pretty_string(&self) -> String
Returns a pretty String representing the castling state
Used for FEN Strings, with (K
| Q
) representing white castling abilities,
and (k
| q
) representing black castling abilities. If there are no bits set,
returns a String containing "-".
Trait Implementations
impl Copy for Castling
impl Copy for Castling
impl PartialEq for Castling
impl PartialEq for Castling
fn eq(&self, other: &Castling) -> bool
fn eq(&self, other: &Castling) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Castling) -> bool
fn ne(&self, other: &Castling) -> bool
This method tests for !=
.
impl Eq for Castling
impl Eq for Castling
impl Clone for Castling
impl Clone for Castling
fn clone(&self) -> Castling
fn clone(&self) -> Castling
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 PartialOrd for Castling
impl PartialOrd for Castling
fn partial_cmp(&self, other: &Castling) -> Option<Ordering>
fn partial_cmp(&self, other: &Castling) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Castling) -> bool
fn lt(&self, other: &Castling) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Castling) -> bool
fn le(&self, other: &Castling) -> 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: &Castling) -> bool
fn gt(&self, other: &Castling) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Castling) -> bool
fn ge(&self, other: &Castling) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for Castling
impl Ord for Castling
fn cmp(&self, other: &Castling) -> Ordering
fn cmp(&self, other: &Castling) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Hash for Castling
impl Hash for Castling
fn hash<__H: Hasher>(&self, state: &mut __H)
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 Debug for Castling
impl Debug for Castling
impl Binary for Castling
impl Binary for Castling
impl Octal for Castling
impl Octal for Castling
impl LowerHex for Castling
impl LowerHex for Castling
impl UpperHex for Castling
impl UpperHex for Castling
impl BitOr for Castling
impl BitOr for Castling
type Output = Castling
The resulting type after applying the |
operator.
fn bitor(self, other: Castling) -> Castling
fn bitor(self, other: Castling) -> Castling
Returns the union of the two sets of flags.
impl BitOrAssign for Castling
impl BitOrAssign for Castling
fn bitor_assign(&mut self, other: Castling)
fn bitor_assign(&mut self, other: Castling)
Adds the set of flags.
impl BitXor for Castling
impl BitXor for Castling
type Output = Castling
The resulting type after applying the ^
operator.
fn bitxor(self, other: Castling) -> Castling
fn bitxor(self, other: Castling) -> Castling
Returns the left flags, but with all the right flags toggled.
impl BitXorAssign for Castling
impl BitXorAssign for Castling
fn bitxor_assign(&mut self, other: Castling)
fn bitxor_assign(&mut self, other: Castling)
Toggles the set of flags.
impl BitAnd for Castling
impl BitAnd for Castling
type Output = Castling
The resulting type after applying the &
operator.
fn bitand(self, other: Castling) -> Castling
fn bitand(self, other: Castling) -> Castling
Returns the intersection between the two sets of flags.
impl BitAndAssign for Castling
impl BitAndAssign for Castling
fn bitand_assign(&mut self, other: Castling)
fn bitand_assign(&mut self, other: Castling)
Disables all flags disabled in the set.
impl Sub for Castling
impl Sub for Castling
type Output = Castling
The resulting type after applying the -
operator.
fn sub(self, other: Castling) -> Castling
fn sub(self, other: Castling) -> Castling
Returns the set difference of the two sets of flags.
impl SubAssign for Castling
impl SubAssign for Castling
fn sub_assign(&mut self, other: Castling)
fn sub_assign(&mut self, other: Castling)
Disables all flags enabled in the set.
impl Not for Castling
impl Not for Castling
type Output = Castling
The resulting type after applying the !
operator.
fn not(self) -> Castling
fn not(self) -> Castling
Returns the complement of this set of flags.
impl Extend<Castling> for Castling
impl Extend<Castling> for Castling
fn extend<T: IntoIterator<Item = Castling>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = Castling>>(&mut self, iterator: T)
Extends a collection with the contents of an iterator. Read more
impl FromIterator<Castling> for Castling
impl FromIterator<Castling> for Castling
fn from_iter<T: IntoIterator<Item = Castling>>(iterator: T) -> Castling
fn from_iter<T: IntoIterator<Item = Castling>>(iterator: T) -> Castling
Creates a value from an iterator. Read more
impl Display for Castling
[src]
impl Display for Castling