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 From<Role> for NonZeroI128
impl From<Role> for NonZeroI128
source§fn from(role: Role) -> NonZeroI128
fn from(role: Role) -> NonZeroI128
Converts to this type from the input type.
source§impl From<Role> for NonZeroI16
impl From<Role> for NonZeroI16
source§fn from(role: Role) -> NonZeroI16
fn from(role: Role) -> NonZeroI16
Converts to this type from the input type.
source§impl From<Role> for NonZeroI32
impl From<Role> for NonZeroI32
source§fn from(role: Role) -> NonZeroI32
fn from(role: Role) -> NonZeroI32
Converts to this type from the input type.
source§impl From<Role> for NonZeroI64
impl From<Role> for NonZeroI64
source§fn from(role: Role) -> NonZeroI64
fn from(role: Role) -> NonZeroI64
Converts to this type from the input type.
source§impl From<Role> for NonZeroIsize
impl From<Role> for NonZeroIsize
source§fn from(role: Role) -> NonZeroIsize
fn from(role: Role) -> NonZeroIsize
Converts to this type from the input type.
source§impl From<Role> for NonZeroU128
impl From<Role> for NonZeroU128
source§fn from(role: Role) -> NonZeroU128
fn from(role: Role) -> NonZeroU128
Converts to this type from the input type.
source§impl From<Role> for NonZeroU16
impl From<Role> for NonZeroU16
source§fn from(role: Role) -> NonZeroU16
fn from(role: Role) -> NonZeroU16
Converts to this type from the input type.
source§impl From<Role> for NonZeroU32
impl From<Role> for NonZeroU32
source§fn from(role: Role) -> NonZeroU32
fn from(role: Role) -> NonZeroU32
Converts to this type from the input type.
source§impl From<Role> for NonZeroU64
impl From<Role> for NonZeroU64
source§fn from(role: Role) -> NonZeroU64
fn from(role: Role) -> NonZeroU64
Converts to this type from the input type.
source§impl From<Role> for NonZeroUsize
impl From<Role> for NonZeroUsize
source§fn from(role: Role) -> NonZeroUsize
fn from(role: Role) -> NonZeroUsize
Converts to this type from the input type.
source§impl Ord for Role
impl Ord for Role
source§impl PartialEq for Role
impl PartialEq for Role
source§impl PartialOrd for Role
impl PartialOrd 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 moreimpl Copy for Role
impl Eq for Role
impl IsEnabled for Role
Available on crate feature
nohash-hasher
only.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