Struct alcibiades::CastlingRights [] [src]

pub struct CastlingRights(_);

Holds information about which player can castle on which side.

The castling rights are held in a usize value. The lowest 4 bits of the value contain the whole needed information. It is laid out in the following way:

 usize                    3   2   1   0
 +----------------------+---+---+---+---+
 |                      |   |   |   |   |
 |    Unused (zeros)    |Castling flags |
 |                      |   |   |   |   |
 +----------------------+---+---+---+---+

 bit 0 -- if set, white can castle on queen-side;
 bit 1 -- if set, white can castle on king-side;
 bit 2 -- if set, black can castle on queen-side;
 bit 3 -- if set, black can castle on king-side.

Methods

impl CastlingRights
[src]

Creates a new instance.

The least significant 4 bits of value are used as a raw value for the new instance.

Returns the contained raw value (between 0 and 15).

Grants a given player the right to castle on a given side.

This method returns true if the player did not have the right to castle on the given side before this method was called, and false otherwise.

Updates the castling rights after played move.

orig_square and dest_square describe the played move.

Returns if a given player has the rights to castle on a given side.

Trait Implementations

impl Clone for CastlingRights
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for CastlingRights
[src]

impl Debug for CastlingRights
[src]

Formats the value using the given formatter.

impl Display for CastlingRights
[src]

Formats the value using the given formatter.