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
Pawn
Knight
Bishop
Rook
Queen
King
Implementations
sourceimpl Role
impl Role
sourcepub fn from_char(ch: char) -> Option<Role>
pub 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 fn char(self) -> char
pub fn char(self) -> char
Gets the English letter for the piece type.
Examples
use shakmaty::Role;
assert_eq!(Role::Rook.char(), 'r');
sourcepub fn upper_char(self) -> char
pub 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
sourceimpl From<Role> for NonZeroI16
impl From<Role> for NonZeroI16
sourcefn from(role: Role) -> NonZeroI16
fn from(role: Role) -> NonZeroI16
Converts to this type from the input type.
sourceimpl From<Role> for NonZeroI32
impl From<Role> for NonZeroI32
sourcefn from(role: Role) -> NonZeroI32
fn from(role: Role) -> NonZeroI32
Converts to this type from the input type.
sourceimpl From<Role> for NonZeroI64
impl From<Role> for NonZeroI64
sourcefn from(role: Role) -> NonZeroI64
fn from(role: Role) -> NonZeroI64
Converts to this type from the input type.
sourceimpl From<Role> for NonZeroIsize
impl From<Role> for NonZeroIsize
sourcefn from(role: Role) -> NonZeroIsize
fn from(role: Role) -> NonZeroIsize
Converts to this type from the input type.
sourceimpl From<Role> for NonZeroU16
impl From<Role> for NonZeroU16
sourcefn from(role: Role) -> NonZeroU16
fn from(role: Role) -> NonZeroU16
Converts to this type from the input type.
sourceimpl From<Role> for NonZeroU32
impl From<Role> for NonZeroU32
sourcefn from(role: Role) -> NonZeroU32
fn from(role: Role) -> NonZeroU32
Converts to this type from the input type.
sourceimpl From<Role> for NonZeroU64
impl From<Role> for NonZeroU64
sourcefn from(role: Role) -> NonZeroU64
fn from(role: Role) -> NonZeroU64
Converts to this type from the input type.
sourceimpl From<Role> for NonZeroUsize
impl From<Role> for NonZeroUsize
sourcefn from(role: Role) -> NonZeroUsize
fn from(role: Role) -> NonZeroUsize
Converts to this type from the input type.
sourceimpl Ord for Role
impl Ord for Role
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<Role> for Role
impl PartialEq<Role> for Role
sourceimpl PartialOrd<Role> for Role
impl PartialOrd<Role> for Role
sourcefn partial_cmp(&self, other: &Role) -> Option<Ordering>
fn partial_cmp(&self, other: &Role) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
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 more
impl Copy for Role
impl Eq for Role
impl StructuralEq for Role
impl StructuralPartialEq for Role
Auto Trait Implementations
impl RefUnwindSafe for Role
impl Send for Role
impl Sync for Role
impl Unpin for Role
impl UnwindSafe for Role
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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