Enum chess::CastleRights
source · pub enum CastleRights {
NoRights,
KingSide,
QueenSide,
Both,
}Expand description
What castle rights does a particular player have?
Variants
NoRights
No right to Castle.
KingSide
Right to Castle only on King side (little Castle).
QueenSide
Right to Castle only on Queen side (big Castle).
Both
Right to Castle in both side (little and big Castle).
Implementations
sourceimpl CastleRights
impl CastleRights
sourcepub fn from_index(index: usize) -> CastleRights
pub fn from_index(index: usize) -> CastleRights
sourcepub fn to_index(&self) -> usize
pub fn to_index(&self) -> usize
Convert CastleRights to usize.
sourcepub fn has_kingside(&self) -> bool
pub fn has_kingside(&self) -> bool
Check the castling on the king side.
sourcepub fn has_queenside(&self) -> bool
pub fn has_queenside(&self) -> bool
Check the castling on the queen side.
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::Black), "");
assert_eq!(CastleRights::KingSide.to_string(Color::White), "K");
assert_eq!(CastleRights::QueenSide.to_string(Color::Black), "q");
assert_eq!(CastleRights::Both.to_string(Color::White), "KQ");Trait Implementations
sourceimpl Clone for CastleRights
impl Clone for CastleRights
sourcefn clone(&self) -> CastleRights
fn clone(&self) -> CastleRights
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresourceimpl Debug for CastleRights
impl Debug for CastleRights
sourceimpl PartialEq<CastleRights> for CastleRights
impl PartialEq<CastleRights> for CastleRights
sourcefn eq(&self, other: &CastleRights) -> bool
fn eq(&self, other: &CastleRights) -> bool
sourceimpl PartialOrd<CastleRights> for CastleRights
impl PartialOrd<CastleRights> for CastleRights
sourcefn partial_cmp(&self, other: &CastleRights) -> Option<Ordering>
fn partial_cmp(&self, other: &CastleRights) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Copy for CastleRights
impl Eq for CastleRights
impl StructuralEq for CastleRights
impl StructuralPartialEq for CastleRights
Auto Trait Implementations
impl RefUnwindSafe for CastleRights
impl Send for CastleRights
impl Sync for CastleRights
impl Unpin for CastleRights
impl UnwindSafe for CastleRights
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more