Struct pleco::board::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 two things for each player 1) What sides are possible to castle from 2) Has this player castled
Does not garauntee 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
fn empty() -> Castling
Returns an empty set of flags.
fn all() -> Castling
Returns the set containing all flags.
fn bits(&self) -> u8
Returns the raw value of the flags currently stored.
fn from_bits(bits: u8) -> Option<Castling>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
fn from_bits_truncate(bits: u8) -> Castling
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
fn is_empty(&self) -> bool
Returns true
if no flags are currently stored.
fn is_all(&self) -> bool
Returns true
if all flags are currently set.
fn intersects(&self, other: Castling) -> bool
Returns true
if there are flags common to both self
and other
.
fn contains(&self, other: Castling) -> bool
Returns true
all of the flags in other
are contained within self
.
fn insert(&mut self, other: Castling)
Inserts the specified flags in-place.
fn remove(&mut self, other: Castling)
Removes the specified flags in-place.
fn toggle(&mut self, other: Castling)
Toggles the specified flags in-place.
fn set(&mut self, other: Castling, value: bool)
Inserts or removes the specified flags depending on the passed value.
impl Castling
[src]
fn remove_player_castling(&mut self, player: Player)
[src]
Removes all castling possibility for a single player
fn remove_king_side_castling(&mut self, player: Player)
[src]
Removes King-Side castling possibility for a single player
fn remove_queen_side_castling(&mut self, player: Player)
[src]
Removes Queen-Side castling possibility for a single player
fn castle_rights(&self, player: Player, side: CastleType) -> bool
[src]
Returns if a player can castle for a given side
fn set_castling(&mut self, player: Player)
[src]
Sets the bits to represent a given player has castled
fn has_castled(&self, player: Player) -> bool
[src]
Returns if a given player has castled
fn no_castling(&self) -> bool
[src]
Returns if both players have lost their ability to castle
fn pretty_string(&self) -> String
[src]
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 PartialEq for Castling
fn eq(&self, __arg_0: &Castling) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Castling) -> bool
This method tests for !=
.
impl Eq for Castling
impl Clone for Castling
fn clone(&self) -> Castling
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialOrd for Castling
fn partial_cmp(&self, __arg_0: &Castling) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Castling) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &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, __arg_0: &Castling) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &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
fn cmp(&self, __arg_0: &Castling) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl Hash for Castling
fn hash<__H: Hasher>(&self, __arg_0: &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]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Debug for Castling
impl Binary for Castling
impl Octal for Castling
impl LowerHex for Castling
impl UpperHex for Castling
impl BitOr for Castling
type Output = Castling
The resulting type after applying the |
operator.
fn bitor(self, other: Castling) -> Castling
Returns the union of the two sets of flags.
impl BitOrAssign for Castling
fn bitor_assign(&mut self, other: Castling)
Adds the set of flags.
impl BitXor for Castling
type Output = Castling
The resulting type after applying the ^
operator.
fn bitxor(self, other: Castling) -> Castling
Returns the left flags, but with all the right flags toggled.
impl BitXorAssign for Castling
fn bitxor_assign(&mut self, other: Castling)
Toggles the set of flags.
impl BitAnd for Castling
type Output = Castling
The resulting type after applying the &
operator.
fn bitand(self, other: Castling) -> Castling
Returns the intersection between the two sets of flags.
impl BitAndAssign for Castling
fn bitand_assign(&mut self, other: Castling)
Disables all flags disabled in the set.
impl Sub for Castling
type Output = Castling
The resulting type after applying the -
operator.
fn sub(self, other: Castling) -> Castling
Returns the set difference of the two sets of flags.
impl SubAssign for Castling
fn sub_assign(&mut self, other: Castling)
Disables all flags enabled in the set.
impl Not for Castling
type Output = Castling
The resulting type after applying the !
operator.
fn not(self) -> Castling
Returns the complement of this set of flags.
impl Extend<Castling> for Castling
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
fn from_iter<T: IntoIterator<Item = Castling>>(iterator: T) -> Castling
Creates a value from an iterator. Read more