Enum shakmaty::Role

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

§

Pawn = 1

§

Knight = 2

§

Bishop = 3

§

Rook = 4

§

Queen = 5

§

King = 6

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] = _

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

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

impl From<Role> for NonZeroI128

source§

fn from(role: Role) -> NonZeroI128

Converts to this type from the input type.
source§

impl From<Role> for NonZeroI16

source§

fn from(role: Role) -> NonZeroI16

Converts to this type from the input type.
source§

impl From<Role> for NonZeroI32

source§

fn from(role: Role) -> NonZeroI32

Converts to this type from the input type.
source§

impl From<Role> for NonZeroI64

source§

fn from(role: Role) -> NonZeroI64

Converts to this type from the input type.
source§

impl From<Role> for NonZeroI8

source§

fn from(role: Role) -> NonZeroI8

Converts to this type from the input type.
source§

impl From<Role> for NonZeroIsize

source§

fn from(role: Role) -> NonZeroIsize

Converts to this type from the input type.
source§

impl From<Role> for NonZeroU128

source§

fn from(role: Role) -> NonZeroU128

Converts to this type from the input type.
source§

impl From<Role> for NonZeroU16

source§

fn from(role: Role) -> NonZeroU16

Converts to this type from the input type.
source§

impl From<Role> for NonZeroU32

source§

fn from(role: Role) -> NonZeroU32

Converts to this type from the input type.
source§

impl From<Role> for NonZeroU64

source§

fn from(role: Role) -> NonZeroU64

Converts to this type from the input type.
source§

impl From<Role> for NonZeroU8

source§

fn from(role: Role) -> NonZeroU8

Converts to this type from the input type.
source§

impl From<Role> for NonZeroUsize

source§

fn from(role: Role) -> NonZeroUsize

Converts to this type from the input type.
source§

impl From<Role> for i128

source§

fn from(value: Role) -> i128

Converts to this type from the input type.
source§

impl From<Role> for i16

source§

fn from(value: Role) -> i16

Converts to this type from the input type.
source§

impl From<Role> for i32

source§

fn from(value: Role) -> i32

Converts to this type from the input type.
source§

impl From<Role> for i64

source§

fn from(value: Role) -> i64

Converts to this type from the input type.
source§

impl From<Role> for i8

source§

fn from(value: Role) -> i8

Converts to this type from the input type.
source§

impl From<Role> for isize

source§

fn from(value: Role) -> isize

Converts to this type from the input type.
source§

impl From<Role> for u128

source§

fn from(value: Role) -> u128

Converts to this type from the input type.
source§

impl From<Role> for u16

source§

fn from(value: Role) -> u16

Converts to this type from the input type.
source§

impl From<Role> for u32

source§

fn from(value: Role) -> u32

Converts to this type from the input type.
source§

impl From<Role> for u64

source§

fn from(value: Role) -> u64

Converts to this type from the input type.
source§

impl From<Role> for u8

source§

fn from(value: Role) -> u8

Converts to this type from the input type.
source§

impl From<Role> for usize

source§

fn from(value: Role) -> usize

Converts to this type from the input type.
source§

impl Hash for Role

source§

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

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) -> Self
where Self: Sized,

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

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

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

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

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

impl PartialEq 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 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<i128> for Role

§

type Error = TryFromIntError

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

fn try_from(value: i128) -> Result<Role, Self::Error>

Performs the conversion.
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, Self::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, Self::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, Self::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, Self::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, Self::Error>

Performs the conversion.
source§

impl TryFrom<u128> for Role

§

type Error = TryFromIntError

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

fn try_from(value: u128) -> Result<Role, Self::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, Self::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, Self::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, Self::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, Self::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, Self::Error>

Performs the conversion.
source§

impl Copy for Role

source§

impl Eq for Role

source§

impl IsEnabled for Role

Available on crate feature nohash-hasher only.
source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where 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 T
where 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 T
where 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.