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 Extend<Role> for MaterialSide
impl Extend<Role> for MaterialSide
sourcefn extend<T: IntoIterator<Item = Role>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Role>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl FromIterator<Role> for MaterialSide
impl FromIterator<Role> for MaterialSide
sourcefn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Role>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Role>,
Creates a value from an iterator. Read more
sourceimpl Ord for Role
impl Ord for Role
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
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>
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 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 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