Struct chess::square::Square [] [src]

pub struct Square(_);

Represent a square on the chess board

Methods

impl Square
[src]

fn new(sq: u8) -> Square

Create a new square, given an index. Note: It is invalid, but allowed, to pass in a number >= 64. Doing so will crash stuff.

fn make_square(rank: u8, file: u8) -> Square

Make a square given a rank and a file Note: It is invalid, but allowed, to pass in a rank or file >= 8. Doing so will crash stuff.

fn up(&self) -> Option<Square>

If there is a square above me, return that. Otherwise, None.

fn forward(&self, color: Color) -> Option<Square>

If there is a square "forward", given my Color, go in that direction. Otherwise, None.

fn backward(&self, color: Color) -> Option<Square>

If there is a square "backward" given my Color, go in that direction. Otherwise, None.

fn down(&self) -> Option<Square>

If there is a square below me, return that. Otherwise, None.

fn left(&self) -> Option<Square>

If there is a square to the left of me, return that. Otherwise, None.

fn right(&self) -> Option<Square>

If there is a square to the right of me, return that. Otherwise, None.

fn uup(&self) -> Square

If there is a square above me, return that. Otherwise, return invalid data to crash the program.

fn udown(&self) -> Square

If there is a square below me, return that. Otherwise, return invalid data to crash the program.

fn uleft(&self) -> Square

If there is a square to the left of me, return that. Otherwise, return invalid data to crash the program.

fn uright(&self) -> Square

If there is a square to the right of me, return that. Otherwise, return invalid data to crash the program.

fn uforward(&self, color: Color) -> Square

If there is a square "forward", given my color, return that. Otherwise, return invalid data to crash the program.

fn ubackward(&self, color: Color) -> Square

If there is a square "backward", given my color, return that. Otherwise, return invalid data to crash the program.

fn rank(&self) -> u8

Return the rank given this square.

fn file(&self) -> u8

Return the file given this square.

fn to_int(&self) -> u8

Convert this square to an integer.

fn to_index(&self) -> usize

Convert this Square to a usize for table lookup purposes

fn from_string(s: String) -> Option<Square>

Convert a UCI String to a square. If invalid, return None

Trait Implementations

impl Clone for Square
[src]

fn clone(&self) -> Square

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl Copy for Square
[src]

impl PartialOrd for Square
[src]

fn partial_cmp(&self, __arg_0: &Square) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more

fn lt(&self, __arg_0: &Square) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more

fn le(&self, __arg_0: &Square) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

fn gt(&self, __arg_0: &Square) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more

fn ge(&self, __arg_0: &Square) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl PartialEq for Square
[src]

fn eq(&self, __arg_0: &Square) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Square) -> bool

This method tests for !=.