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§
Implementations§
source§impl 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.
pub fn disambiguate( m: &Move, moves: &ArrayVec<Move, shakmaty::::movelist::MoveList::{constant#0}> ) -> San
sourcepub fn find_move<'a>(
&self,
moves: &'a ArrayVec<Move, shakmaty::::movelist::MoveList::{constant#0}>
) -> Result<&'a Move, SanError>
pub fn find_move<'a>( &self, moves: &'a ArrayVec<Move, shakmaty::::movelist::MoveList::{constant#0}> ) -> Result<&'a Move, SanError>
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, 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§
impl Eq for San
impl StructuralPartialEq for San
Auto Trait Implementations§
impl Freeze for San
impl RefUnwindSafe for San
impl Send for San
impl Sync for San
impl Unpin for San
impl UnwindSafe for San
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more