Enum chess_notation_parser::Turn
source · [−]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
Castling(Castling)
Move(Move)
Implementations
Trait Implementations
impl StructuralPartialEq for Turn
Auto Trait Implementations
impl RefUnwindSafe for Turn
impl Send for Turn
impl Sync for Turn
impl Unpin for Turn
impl UnwindSafe for Turn
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more