pub enum Turn {
Castling(Castling),
Move(Move),
}
Expand description
§Struct representation of a string formatted chess turn
Turn can be either Move
or Castling
turn.
§Example for Move
use chess_notation_parser::{Turn, Move, Square, Piece, Flag};
let turn = Turn::Move(
Move {
who: Piece::Queen,
dst: Square::D7,
flags: Flag::NONE,
src: None,
promotion: None,
}
);
assert_eq!(turn, Turn::try_from("Qd7").unwrap());
// Turn::Move can be created with macro
use chess_notation_parser::turn_move;
let turn = turn_move!(Piece::Bishop, Square::C4);
assert_eq!(turn, Turn::try_from("Bc4").unwrap());
let turn = turn_move!(
Piece::King,
Square::D5,
Flag::CAPTURE,
Some(vec![Square::E3])
);
assert_eq!(turn, Turn::try_from("Ke3xd5").unwrap());
§Example for Castling
use chess_notation_parser::{Turn, Castling, CastlingType, Flag};
use chess_notation_parser::turn_castling;
let turn = turn_castling!(
CastlingType::Long,
Flag::NONE
);
assert_eq!(turn, Turn::try_from("0-0-0").unwrap());
Variants§
Implementations§
Trait Implementations§
impl StructuralPartialEq for Turn
Auto Trait Implementations§
impl Freeze for Turn
impl RefUnwindSafe for Turn
impl Send for Turn
impl Sync for Turn
impl Unpin for Turn
impl UnwindSafe for Turn
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