Struct hexe_core::mv::Move
[−]
[src]
pub struct Move(_);
A chess piece move from one square to another.
Each instance has the following memory layout:
Methods
impl Move
[src]
pub fn normal(src: Square, dst: Square) -> Move
[src]
Creates a new Move
from one square to another.
pub fn promotion(file: File, color: Color, piece: Promotion) -> Move
[src]
Creates a new promotion move for color
at file
.
pub fn castle(right: Right) -> Move
[src]
Creates a new castle move for right
.
pub fn en_passant(src: Square, dst: Square) -> Option<Move>
[src]
Creates an en passant move from one square to another.
pub fn squares_eq<T: Into<Move>>(self, other: T) -> bool
[src]
Returns whether the squares of self
equal the squares of other
.
pub fn src(self) -> Square
[src]
Returns the source square for self
.
pub fn dst(self) -> Square
[src]
Returns the destination square for self
.
pub fn kind(self) -> Kind
[src]
Returns the kind for self
.
pub fn to_castle(self) -> Option<Castle>
[src]
Returns self
a castle move if it can be converted into one.
pub fn to_en_passant(self) -> Option<EnPassant>
[src]
Returns self
as an en passant move if it can be converted into one.
pub fn matches(self) -> Matches
[src]
Returns a match
-able type that represents the inner variant of self
.
Examples
Basic usage:
use hexe_core::mv::{Move, Matches}; use hexe_core::square::Square; let mv = Move::normal(Square::A1, Square::A7); match mv.matches() { Matches::Normal(mv) => println!("{:?}", mv.src()), Matches::Castle(mv) => println!("{:?}", mv.right()), Matches::Promotion(mv) => println!("{:?}", mv.piece()), Matches::EnPassant(mv) => println!("{:?}", mv.capture()), }
Trait Implementations
impl From<Normal> for Move
[src]
impl FromUnchecked<Move> for Normal
[src]
unsafe fn from_unchecked(mv: Move) -> Normal
[src]
Performs the unchecked conversion.
impl AsRef<Move> for Normal
[src]
impl From<Castle> for Move
[src]
impl FromUnchecked<Move> for Castle
[src]
unsafe fn from_unchecked(mv: Move) -> Castle
[src]
Performs the unchecked conversion.
impl AsRef<Move> for Castle
[src]
impl From<Promotion> for Move
[src]
impl FromUnchecked<Move> for Promotion
[src]
unsafe fn from_unchecked(mv: Move) -> Promotion
[src]
Performs the unchecked conversion.
impl AsRef<Move> for Promotion
[src]
impl From<EnPassant> for Move
[src]
impl FromUnchecked<Move> for EnPassant
[src]
unsafe fn from_unchecked(mv: Move) -> EnPassant
[src]
Performs the unchecked conversion.
impl AsRef<Move> for EnPassant
[src]
impl From<Right> for Move
[src]
impl PartialEq for Move
[src]
fn eq(&self, __arg_0: &Move) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Move) -> bool
[src]
This method tests for !=
.
impl Eq for Move
[src]
impl Clone for Move
[src]
fn clone(&self) -> Move
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for Move
[src]
impl Hash for Move
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl FromUnchecked<u16> for Move
[src]
unsafe fn from_unchecked(inner: u16) -> Self
[src]
Performs the unchecked conversion.
impl From<Move> for u16
[src]
impl Debug for Move
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more