[]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

pub const WHITE_K: Castling

pub const WHITE_Q: Castling

pub const BLACK_K: Castling

pub const BLACK_Q: Castling

pub const WHITE_ALL: Castling

pub const BLACK_ALL: Castling

pub fn empty() -> Castling

Returns an empty set of flags.

pub fn all() -> Castling

Returns the set containing all flags.

pub fn bits(&self) -> u8

Returns the raw value of the flags currently stored.

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

Convert from underlying bit representation, dropping any bits that do not correspond to flags.

pub fn is_empty(&self) -> bool

Returns true if no flags are currently stored.

pub fn is_all(&self) -> bool

Returns true if all flags are currently set.

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

Returns true all of the flags in other are contained within self.

pub fn insert(&mut self, other: Castling)

Inserts the specified flags in-place.

pub fn remove(&mut self, other: Castling)

Removes the specified flags in-place.

pub fn toggle(&mut self, other: Castling)

Toggles the specified flags in-place.

pub fn set(&mut self, other: Castling, value: bool)

Inserts or removes the specified flags depending on the passed value.

impl Castling[src]

pub fn remove_player_castling(&mut self, player: Player)[src]

Removes all castling possibility for a single player

pub fn remove_king_side_castling(&mut self, player: Player)[src]

Removes King-Side castling possibility for a single player

pub fn remove_queen_side_castling(&mut self, player: Player)[src]

Removes Queen-Side castling possibility for a single player

pub fn castle_rights(self, player: Player, side: CastleType) -> bool[src]

Returns if a player can castle for a given side

pub fn player_can_castle(self, player: Player) -> Castling[src]

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

Returns if both players have lost their ability to castle

pub fn update_castling(&mut self, to: SQ, from: SQ) -> u8[src]

pub fn add_castling_char(&mut self, c: char)[src]

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]

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 Eq for Castling

impl Copy for Castling

impl PartialOrd<Castling> for Castling

impl PartialEq<Castling> for Castling

impl Clone for Castling

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

Performs copy-assignment from source. Read more

impl Ord for Castling

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl Extend<Castling> for Castling

impl Display for Castling[src]

impl Debug for Castling

impl Sub<Castling> 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<Castling> 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 BitAnd<Castling> 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 BitOr<Castling> 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 BitXor<Castling> 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 BitAndAssign<Castling> for Castling

fn bitand_assign(&mut self, other: Castling)

Disables all flags disabled in the set.

impl BitOrAssign<Castling> for Castling

fn bitor_assign(&mut self, other: Castling)

Adds the set of flags.

impl BitXorAssign<Castling> for Castling

fn bitxor_assign(&mut self, other: Castling)

Toggles the set of flags.

impl Hash for Castling

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

impl FromIterator<Castling> for Castling

impl Octal for Castling

impl Binary for Castling

impl LowerHex for Castling

impl UpperHex for Castling

Auto Trait Implementations

impl Send for Castling

impl Sync for Castling

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.