Enum pgn_reader::Role
source · pub enum Role {
Pawn,
Knight,
Bishop,
Rook,
Queen,
King,
}
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 PartialEq<Role> for Role
impl PartialEq<Role> for Role
source§impl PartialOrd<Role> for Role
impl PartialOrd<Role> for Role
1.0.0 · source§fn 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 more