Module shakmaty::san

source ·
Expand description

Read and write Standard Algebraic Notation.

§Examples

Parse and write SANs:

use shakmaty::{Chess, Position, san::San};

let san: San = "Nf3".parse()?;
assert_eq!(san.to_string(), "Nf3");

Converting to a move:

use shakmaty::{Square, Role, Move};
let pos = Chess::default();
let m = san.to_move(&pos)?;

assert_eq!(m, Move::Normal {
    role: Role::Knight,
    from: Square::G1,
    capture: None,
    to: Square::F3,
    promotion: None,
});

Back to a (possibly disambiguated) SAN:

assert_eq!(San::from_move(&pos, &m).to_string(), "Nf3");

Structs§

Enums§

  • A move in Standard Algebraic Notation.
  • IllegalSan or AmbiguousSan.
  • Check (+) or checkmate (#) suffix.