pub struct Piece {
pub color: Color,
pub kind: Kind,
}Expand description
Represents a chess piece.
§Examples
use chessly::{Color, Kind, Piece};
let piece = Piece::new(Color::White, Kind::King);
assert_eq!(piece.to_symbol(), 'K');
let piece = Piece::new(Color::Black, Kind::Pawn);
assert_eq!(piece.to_symbol(), 'p');Fields§
§color: Color§kind: KindImplementations§
Source§impl Piece
impl Piece
Sourcepub const fn to_symbol(&self) -> char
pub const fn to_symbol(&self) -> char
Returns the piece’s symbol. White pieces are uppercase, black pieces are lowercase.
§Examples
use chessly::{Color, Kind, Piece};
let piece = Piece::new(Color::White, Kind::King);
assert_eq!(piece.to_symbol(), 'K');
let piece = Piece::new(Color::Black, Kind::Pawn);
assert_eq!(piece.to_symbol(), 'p');Sourcepub const fn to_unicode_symbol(&self) -> char
pub const fn to_unicode_symbol(&self) -> char
Returns the piece’s unicode symbol.
§Examples
use chessly::{Color, Kind, Piece};
let piece = Piece::new(Color::White, Kind::King);
assert_eq!(piece.to_unicode_symbol(), '\u{2654}');
let piece = Piece::new(Color::Black, Kind::Pawn);
assert_eq!(piece.to_unicode_symbol(), '\u{265f}');Trait Implementations§
impl Copy for Piece
impl Eq for Piece
impl StructuralPartialEq for Piece
Auto Trait Implementations§
impl Freeze for Piece
impl RefUnwindSafe for Piece
impl Send for Piece
impl Sync for Piece
impl Unpin for Piece
impl UnwindSafe for Piece
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