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§
- Parse
SanError - Error when parsing a syntactically invalid SAN.
- SanPlus
- A
San
and possible check and checkmate suffixes.