Struct shogi::piece::Piece [−][src]
Expand description
Represents a piece on the game board.
Fields
piece_type: PieceType
color: Color
Implementations
Creates a new instance of Piece
from SFEN formatted string.
Returns an instance of Piece
after promotion.
Examples
use shogi::{Color, PieceType, Piece};
let pc1 = Piece{piece_type: PieceType::Pawn, color: Color::Black};
let pc2 = Piece{piece_type: PieceType::ProPawn, color: Color::Black};
assert_eq!(Some(pc2), pc1.promote());
assert_eq!(None, pc2.promote());
Returns an instance of Piece
before promotion.
Examples
use shogi::{Color, PieceType, Piece};
let pc1 = Piece{piece_type: PieceType::Pawn, color: Color::Black};
let pc2 = Piece{piece_type: PieceType::ProPawn, color: Color::Black};
assert_eq!(Some(pc1), pc2.unpromote());
assert_eq!(None, pc1.unpromote());
Returns an instance of Piece
with the reversed color.
Examples
use shogi::{Color, PieceType, Piece};
let pc1 = Piece{piece_type: PieceType::Pawn, color: Color::Black};
let pc2 = Piece{piece_type: PieceType::Pawn, color: Color::White};
assert_eq!(pc2, pc1.flip());
assert_eq!(pc1, pc2.flip());
Tests if it is legal to place this piece at the given square.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Piece
impl UnwindSafe for Piece
Blanket Implementations
Mutably borrows from an owned value. Read more