#[repr(u8)]pub enum CastleRights {
NoRights = 0,
KingSide = 1,
QueenSide = 2,
Both = 3,
}Expand description
What castle rights does a particular player have?
Variants§
Implementations§
Source§impl CastleRights
impl CastleRights
Sourcepub fn has_kingside(&self) -> bool
pub fn has_kingside(&self) -> bool
Can I castle kingside?
Sourcepub fn has_queenside(&self) -> bool
pub fn has_queenside(&self) -> bool
Can I castle queenside?
pub fn square_to_castle_rights(color: Color, sq: Square) -> CastleRights
Sourcepub fn kingside_squares(&self, color: Color) -> BitBoard ⓘ
pub fn kingside_squares(&self, color: Color) -> BitBoard ⓘ
What squares need to be empty to castle kingside?
Sourcepub fn queenside_squares(&self, color: Color) -> BitBoard ⓘ
pub fn queenside_squares(&self, color: Color) -> BitBoard ⓘ
What squares need to be empty to castle queenside?
Sourcepub fn remove(&self, remove: CastleRights) -> CastleRights
pub fn remove(&self, remove: CastleRights) -> CastleRights
Remove castle rights, and return a new CastleRights.
Sourcepub fn add(&self, add: CastleRights) -> CastleRights
pub fn add(&self, add: CastleRights) -> CastleRights
Add some castle rights, and return a new CastleRights.
Sourcepub fn from_index(i: usize) -> CastleRights
pub fn from_index(i: usize) -> CastleRights
Convert usize to CastleRights.
Sourcepub fn unmoved_rooks(&self, color: Color) -> BitBoard ⓘ
pub fn unmoved_rooks(&self, color: Color) -> BitBoard ⓘ
Which rooks can we “guarantee” we haven’t moved yet?
Sourcepub fn to_string(&self, color: Color) -> String
pub fn to_string(&self, color: Color) -> String
Convert the castle rights to an FEN compatible string.
use chess::{CastleRights, Color};
assert_eq!(CastleRights::NoRights.to_string(Color::White), "");
assert_eq!(CastleRights::Both.to_string(Color::Black), "kq");
assert_eq!(CastleRights::KingSide.to_string(Color::White), "K");
assert_eq!(CastleRights::QueenSide.to_string(Color::Black), "q");Sourcepub fn rook_square_to_castle_rights(square: Square) -> CastleRights
pub fn rook_square_to_castle_rights(square: Square) -> CastleRights
Given a square of a rook, which side is it on?
Trait Implementations§
Source§impl Clone for CastleRights
impl Clone for CastleRights
impl Copy for CastleRights
Source§impl Debug for CastleRights
impl Debug for CastleRights
impl Eq for CastleRights
Source§impl Hash for CastleRights
impl Hash for CastleRights
Source§impl PartialEq for CastleRights
impl PartialEq for CastleRights
Source§impl PartialOrd for CastleRights
impl PartialOrd for CastleRights
impl StructuralPartialEq for CastleRights
Auto Trait Implementations§
impl Freeze for CastleRights
impl RefUnwindSafe for CastleRights
impl Send for CastleRights
impl Sync for CastleRights
impl Unpin for CastleRights
impl UnsafeUnpin for CastleRights
impl UnwindSafe for CastleRights
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more