pub struct PieceMove {
pub from: SquareCoordinates,
pub to: SquareCoordinates,
pub promotion: Option<Kind>,
}Fields§
§from: SquareCoordinates§to: SquareCoordinates§promotion: Option<Kind>Implementations§
Source§impl PieceMove
Represents a move of a piece on the board.
impl PieceMove
Represents a move of a piece on the board.
§Examples
use chessly::{Kind, PieceMove, SquareCoordinates};
let from = SquareCoordinates::try_from("e2").unwrap();
let to = SquareCoordinates::try_from("e4").unwrap();
let piece_move = PieceMove::new(from, to);
assert_eq!(piece_move.to_string(), "e2e4");pub const fn new(from: SquareCoordinates, to: SquareCoordinates) -> Self
pub const fn promotion( from: SquareCoordinates, to: SquareCoordinates, promotion: Kind, ) -> Self
Source§impl PieceMove
impl PieceMove
Sourcepub fn to_long_algebraic_notation(&self) -> String
pub fn to_long_algebraic_notation(&self) -> String
Returns the long algebraic notation of the move.
Read more about long algebraic notation here.
§Examples
use chessly::{Kind, PieceMove, SquareCoordinates};
let from = SquareCoordinates::try_from("e2").unwrap();
let to = SquareCoordinates::try_from("e4").unwrap();
let piece_move = PieceMove::new(from, to);
assert_eq!(piece_move.to_long_algebraic_notation(), "e2e4");
let from = SquareCoordinates::try_from("e7").unwrap();
let to = SquareCoordinates::try_from("e8").unwrap();
let piece_move = PieceMove::promotion(from, to, Kind::Queen);
assert_eq!(piece_move.to_long_algebraic_notation(), "e7e8q");Trait Implementations§
impl Copy for PieceMove
impl Eq for PieceMove
impl StructuralPartialEq for PieceMove
Auto Trait Implementations§
impl Freeze for PieceMove
impl RefUnwindSafe for PieceMove
impl Send for PieceMove
impl Sync for PieceMove
impl Unpin for PieceMove
impl UnwindSafe for PieceMove
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