Enum pgn_reader::San
source · 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
Normal
Castle(CastlingSide)
Put
Null
Implementations
sourceimpl San
impl San
sourcepub fn from_ascii(san: &[u8]) -> Result<San, ParseSanError>
pub fn from_ascii(san: &[u8]) -> Result<San, ParseSanError>
Parses a SAN. Ignores a possible check or checkmate suffix.
Errors
Returns ParseSanError
if san
is not syntactically valid.
sourcepub fn from_move<P>(pos: &P, m: &Move) -> Sanwhere
P: Position,
pub fn from_move<P>(pos: &P, m: &Move) -> Sanwhere
P: Position,
Converts a move to Standard Algebraic Notation.
sourcepub fn matches(&self, m: &Move) -> bool
pub fn matches(&self, m: &Move) -> bool
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
sourceimpl FromStr for San
impl FromStr for San
type Err = ParseSanError
type Err = ParseSanError
The associated error which can be returned from parsing.
impl Eq for San
impl StructuralEq for San
impl StructuralPartialEq for San
Auto Trait Implementations
impl RefUnwindSafe for San
impl Send for San
impl Sync for San
impl Unpin for San
impl UnwindSafe for San
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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