[][src]Enum pgn_reader::San

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,
}

A move in Standard Algebraic Notation.

Variants

Normal

Fields of Normal

role: Rolefile: Option<File>rank: Option<Rank>capture: boolto: Squarepromotion: Option<Role>
Castle(CastlingSide)Put

Fields of Put

role: Roleto: Square
Null

Methods

impl San[src]

pub fn from_ascii(san: &[u8]) -> Result<San, ParseSanError>[src]

Parses a SAN. Ignores a possible check or checkmate suffix.

Errors

Returns ParseSanError if san is not syntactically valid.

pub fn from_move<P>(pos: &P, m: &Move) -> San where
    P: Position
[src]

Converts a move to Standard Algebraic Notation.

pub fn to_move<P>(&self, pos: &P) -> Result<Move, SanError> where
    P: Position
[src]

Tries to convert the San to a legal move in the context of a position.

Errors

Returns SanError if there is no unique matching legal move.

pub fn disambiguate(m: &Move, moves: &ArrayVec<[Move; 512]>) -> San[src]

pub fn find_move(
    &self,
    moves: &'a ArrayVec<[Move; 512]>
) -> Result<&'a Move, SanError>
[src]

Searches a MoveList for a unique matching move.

Errors

Returns SanError if there is no unique matching legal move.

pub fn matches(&self, m: &Move) -> bool[src]

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

impl Clone for San[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl FromStr for San[src]

type Err = ParseSanError

The associated error which can be returned from parsing.

impl Eq for San[src]

impl PartialEq<San> for San[src]

impl Display for San[src]

impl Hash for San[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for San[src]

Auto Trait Implementations

impl Sync for San

impl Send for San

impl Unpin for San

impl RefUnwindSafe for San

impl UnwindSafe for San

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]