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§

§

Pawn

§

Knight

§

Bishop

§

Rook

§

Queen

§

King

Implementations§

source§

impl Role

source

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);
source

pub const fn of(self, color: Color) -> Piece

Gets a Piece of the given color.

Examples
use shakmaty::{Color, Role};

assert_eq!(Role::King.of(Color::Black), Color::Black.king());
source

pub const fn char(self) -> char

Gets the English letter for the piece type.

Examples
use shakmaty::Role;

assert_eq!(Role::Rook.char(), 'r');
source

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');
source

pub const ALL: [Role; 6] = [Role::Pawn, Role::Knight, Role::Bishop, Role::Rook, Role::Queen, Role::King]

Pawn, Knight, Bishop, Rook, Queen, and King, in this order.

Trait Implementations§

source§

impl Clone for Role

source§

fn clone(&self) -> Role

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Role

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Hash for Role

source§

fn hash<__H>(&self, state: &mut __H)where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Role

source§

fn cmp(&self, other: &Role) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Role> for Role

source§

fn eq(&self, other: &Role) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Role> for Role

source§

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 · source§

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 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<i16> for Role

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: i16) -> Result<Role, <Role as TryFrom<i16>>::Error>

Performs the conversion.
source§

impl TryFrom<i32> for Role

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: i32) -> Result<Role, <Role as TryFrom<i32>>::Error>

Performs the conversion.
source§

impl TryFrom<i64> for Role

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: i64) -> Result<Role, <Role as TryFrom<i64>>::Error>

Performs the conversion.
source§

impl TryFrom<i8> for Role

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: i8) -> Result<Role, <Role as TryFrom<i8>>::Error>

Performs the conversion.
source§

impl TryFrom<isize> for Role

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: isize) -> Result<Role, <Role as TryFrom<isize>>::Error>

Performs the conversion.
source§

impl TryFrom<u16> for Role

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: u16) -> Result<Role, <Role as TryFrom<u16>>::Error>

Performs the conversion.
source§

impl TryFrom<u32> for Role

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: u32) -> Result<Role, <Role as TryFrom<u32>>::Error>

Performs the conversion.
source§

impl TryFrom<u64> for Role

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: u64) -> Result<Role, <Role as TryFrom<u64>>::Error>

Performs the conversion.
source§

impl TryFrom<u8> for Role

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: u8) -> Result<Role, <Role as TryFrom<u8>>::Error>

Performs the conversion.
source§

impl TryFrom<usize> for Role

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: usize) -> Result<Role, <Role as TryFrom<usize>>::Error>

Performs the conversion.
source§

impl Copy for Role

source§

impl Eq for Role

source§

impl StructuralEq for Role

source§

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.