pub enum Role {
Pawn = 1,
Knight = 2,
Bishop = 3,
Rook = 4,
Queen = 5,
King = 6,
}Expand description
Piece types: Pawn, Knight, Bishop, Rook, Queen, King.
§Examples
use shakmaty::Role;
// Piece types are indexed from 1 to 6.
assert_eq!(u32::from(Role::Pawn), 1);
assert_eq!(u32::from(Role::King), 6);Variants§
Implementations§
Source§impl Role
impl Role
Sourcepub const fn from_char(ch: char) -> Option<Role>
pub const fn from_char(ch: char) -> Option<Role>
Gets the piece type from its English letter.
§Examples
use shakmaty::Role;
assert_eq!(Role::from_char('K'), Some(Role::King));
assert_eq!(Role::from_char('n'), Some(Role::Knight));
assert_eq!(Role::from_char('X'), None);Sourcepub const fn char(self) -> char
pub const fn char(self) -> char
Gets the English letter for the piece type.
§Examples
use shakmaty::Role;
assert_eq!(Role::Rook.char(), 'r');Sourcepub const fn upper_char(self) -> char
pub const fn upper_char(self) -> char
Gets the uppercase English letter for the piece type.
§Examples
use shakmaty::Role;
assert_eq!(Role::Rook.upper_char(), 'R');Trait Implementations§
Source§impl Ord for Role
impl Ord for Role
Source§impl PartialOrd for Role
impl PartialOrd for Role
impl Copy for Role
impl Eq for Role
impl StructuralPartialEq for Role
Auto Trait Implementations§
impl Freeze for Role
impl RefUnwindSafe for Role
impl Send for Role
impl Sync for Role
impl Unpin for Role
impl UnwindSafe for Role
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