Represents a piece on the game board.
Creates a new instance of Piece
from SFEN formatted string.
Returns an instance of Piece
after promotion.
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.
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.
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.
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String
. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more