Enum pgn_reader::San [−][src]
pub enum San {
Normal {
role: Role,
file: Option<File>,
rank: Option<Rank>,
capture: bool,
to: Square,
promotion: Option<Role>,
},
Castle(CastlingSide),
Put {
role: Role,
to: Square,
},
Null,
}Expand description
A move in Standard Algebraic Notation.
Variants
Fields of Normal
Castle(CastlingSide)Tuple Fields of Castle
0: CastlingSideImplementations
Parses a SAN. Ignores a possible check or checkmate suffix.
Errors
Returns ParseSanError if san is not syntactically valid.
Converts a move to Standard Algebraic Notation.
Test if the San can match the Move (in any position).
Examples
use shakmaty::{Square, Role, Move};
use shakmaty::san::San;
let m = Move::Normal {
role: Role::Knight,
from: Square::G1,
to: Square::F3,
capture: None,
promotion: None,
};
let nf3 = San::from_ascii(b"Nf3")?;
assert!(nf3.matches(&m));
let ng1f3 = San::from_ascii(b"Ng1f3")?;
assert!(ng1f3.matches(&m));
// capture does not match
let nxf3 = San::from_ascii(b"Nxf3")?;
assert!(!nxf3.matches(&m));
// other file does not match
let nef3 = San::from_ascii(b"Nef3")?;
assert!(!nef3.matches(&m));Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for San
impl UnwindSafe for San
Blanket Implementations
Mutably borrows from an owned value. Read more