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) -> San where
P: Position,
pub fn from_move<P>(pos: &P, m: &Move) -> San where
P: Position,
Converts a move to Standard Algebraic Notation.
pub fn disambiguate(m: &Move, moves: &ArrayVec<Move, {_: usize}>) -> San
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
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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more