Struct chess::Square [−][src]
pub struct Square(_);
Represent a square on the chess board
Methods
impl Square
[src]
impl Square
pub unsafe fn new(sq: u8) -> Square
[src]
pub unsafe 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.
pub fn make_square(rank: Rank, file: File) -> Square
[src]
pub fn make_square(rank: Rank, file: File) -> Square
Make a square given a rank and a file
pub fn get_rank(&self) -> Rank
[src]
pub fn get_rank(&self) -> Rank
Return the rank given this square.
pub fn get_file(&self) -> File
[src]
pub fn get_file(&self) -> File
Return the file given this square.
pub fn up(&self) -> Option<Square>
[src]
pub fn up(&self) -> Option<Square>
If there is a square above me, return that. Otherwise, None.
pub fn down(&self) -> Option<Square>
[src]
pub fn down(&self) -> Option<Square>
If there is a square below me, return that. Otherwise, None.
pub fn left(&self) -> Option<Square>
[src]
pub fn left(&self) -> Option<Square>
If there is a square to the left of me, return that. Otherwise, None.
pub fn right(&self) -> Option<Square>
[src]
pub fn right(&self) -> Option<Square>
If there is a square to the right of me, return that. Otherwise, None.
pub fn forward(&self, color: Color) -> Option<Square>
[src]
pub fn forward(&self, color: Color) -> Option<Square>
If there is a square "forward", given my Color
, go in that direction. Otherwise, None.
pub fn backward(&self, color: Color) -> Option<Square>
[src]
pub fn backward(&self, color: Color) -> Option<Square>
If there is a square "backward" given my Color
, go in that direction. Otherwise, None.
pub fn uup(&self) -> Square
[src]
pub fn uup(&self) -> Square
If there is a square above me, return that. If not, wrap around to the other side.
pub fn udown(&self) -> Square
[src]
pub fn udown(&self) -> Square
If there is a square below me, return that. If not, wrap around to the other side.
pub fn uleft(&self) -> Square
[src]
pub fn uleft(&self) -> Square
If there is a square to the left of me, return that. If not, wrap around to the other side.
pub fn uright(&self) -> Square
[src]
pub fn uright(&self) -> Square
If there is a square to the right of me, return that. If not, wrap around to the other side.
pub fn uforward(&self, color: Color) -> Square
[src]
pub fn uforward(&self, color: Color) -> Square
If there is a square "forward", given my color, return that. If not, wrap around to the other side.
pub fn ubackward(&self, color: Color) -> Square
[src]
pub fn ubackward(&self, color: Color) -> Square
If there is a square "backward", given my color, return that. If not, wrap around to the other side.
pub fn to_int(&self) -> u8
[src]
pub fn to_int(&self) -> u8
Convert this square to an integer.
pub fn to_index(&self) -> usize
[src]
pub fn to_index(&self) -> usize
Convert this Square
to a usize
for table lookup purposes
pub fn from_string(s: String) -> Option<Square>
[src]
pub fn from_string(s: String) -> Option<Square>
Convert a UCI String
to a square. If invalid, return None
Trait Implementations
impl PartialEq for Square
[src]
impl PartialEq for Square
fn eq(&self, other: &Square) -> bool
[src]
fn eq(&self, other: &Square) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Square) -> bool
[src]
fn ne(&self, other: &Square) -> bool
This method tests for !=
.
impl Ord for Square
[src]
impl Ord for Square
fn cmp(&self, other: &Square) -> Ordering
[src]
fn cmp(&self, other: &Square) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Eq for Square
[src]
impl Eq for Square
impl PartialOrd for Square
[src]
impl PartialOrd for Square
fn partial_cmp(&self, other: &Square) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Square) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Square) -> bool
[src]
fn lt(&self, other: &Square) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Square) -> bool
[src]
fn le(&self, other: &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, other: &Square) -> bool
[src]
fn gt(&self, other: &Square) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Square) -> bool
[src]
fn ge(&self, other: &Square) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Copy for Square
[src]
impl Copy for Square
impl Clone for Square
[src]
impl Clone for Square
fn clone(&self) -> Square
[src]
fn clone(&self) -> Square
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Display for Square
[src]
impl Display for Square