pub struct ChessMove { /* private fields */ }Expand description
Represent a ChessMove in memory
Implementations§
Source§impl ChessMove
impl ChessMove
Sourcepub fn new(source: Square, dest: Square, promotion: Option<Piece>) -> ChessMove
pub fn new(source: Square, dest: Square, promotion: Option<Piece>) -> ChessMove
Create a new chess move, given a source Square, a destination Square, and an optional
promotion Piece
Sourcepub fn get_source(&self) -> Square
pub fn get_source(&self) -> Square
Get the source square (square the piece is currently on).
Sourcepub fn get_promotion(&self) -> Option<Piece>
pub fn get_promotion(&self) -> Option<Piece>
Get the promotion piece (maybe).
Sourcepub fn from_san(board: &Board, move_text: &str) -> Result<ChessMove, Error>
pub fn from_san(board: &Board, move_text: &str) -> Result<ChessMove, Error>
Convert a SAN (Standard Algebraic Notation) move into a ChessMove
use chess::{Board, ChessMove, Square};
let board = Board::default();
assert_eq!(
ChessMove::from_san(&board, "e4").expect("e4 is valid in the initial position"),
ChessMove::new(Square::E2, Square::E4, None)
);Trait Implementations§
Source§impl FromStr for ChessMove
Convert a UCI String to a move. If invalid, return None
impl FromStr for ChessMove
Convert a UCI String to a move. If invalid, return None
use chess::{ChessMove, Square, Piece};
use std::str::FromStr;
let mv = ChessMove::new(Square::E7, Square::E8, Some(Piece::Queen));
assert_eq!(ChessMove::from_str("e7e8q").expect("Valid Move"), mv);Source§impl Ord for ChessMove
impl Ord for ChessMove
Source§impl PartialOrd for ChessMove
impl PartialOrd for ChessMove
impl Copy for ChessMove
impl Eq for ChessMove
impl StructuralPartialEq for ChessMove
Auto Trait Implementations§
impl Freeze for ChessMove
impl RefUnwindSafe for ChessMove
impl Send for ChessMove
impl Sync for ChessMove
impl Unpin for ChessMove
impl UnwindSafe for ChessMove
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