#[repr(u8)]
pub enum Square {
Show 64 variants
A1,
B1,
C1,
D1,
E1,
F1,
G1,
H1,
A2,
B2,
C2,
D2,
E2,
F2,
G2,
H2,
A3,
B3,
C3,
D3,
E3,
F3,
G3,
H3,
A4,
B4,
C4,
D4,
E4,
F4,
G4,
H4,
A5,
B5,
C5,
D5,
E5,
F5,
G5,
H5,
A6,
B6,
C6,
D6,
E6,
F6,
G6,
H6,
A7,
B7,
C7,
D7,
E7,
F7,
G7,
H7,
A8,
B8,
C8,
D8,
E8,
F8,
G8,
H8,
}Expand description
Represent a square on the chess board.
Variants
A1
B1
C1
D1
E1
F1
G1
H1
A2
B2
C2
D2
E2
F2
G2
H2
A3
B3
C3
D3
E3
F3
G3
H3
A4
B4
C4
D4
E4
F4
G4
H4
A5
B5
C5
D5
E5
F5
G5
H5
A6
B6
C6
D6
E6
F6
G6
H6
A7
B7
C7
D7
E7
F7
G7
H7
A8
B8
C8
D8
E8
F8
G8
H8
Implementations
sourceimpl Square
impl Square
sourcepub fn make_square(file: File, rank: Rank) -> Square
pub fn make_square(file: File, rank: Rank) -> Square
sourcepub fn from_screen(x: f32, y: f32) -> Square
pub fn from_screen(x: f32, y: f32) -> Square
Transform a screen coordinate into a Square.
Reciprocal: see
Square::to_screen.
The result depend of:
sourcepub fn to_screen(&self) -> (f32, f32)
pub fn to_screen(&self) -> (f32, f32)
Transform a Square into a screen coordinate.
Reciprocal: see
Square::from_screen.
The result depend of:
sourcepub fn rank_for(&self, color: Color) -> Rank
pub fn rank_for(&self, color: Color) -> Rank
Return the “relative” Rank of this square according the side.
(i.e. return ranks for black)
Examples
use chess::{Color, Rank, Square};
assert_eq!(Square::E1.rank_for(Color::White), Rank::First);
assert_eq!(Square::E8.rank_for(Color::White), Rank::Eighth);
assert_eq!(Square::E2.rank_for(Color::Black), Rank::Seventh);
assert_eq!(Square::E7.rank_for(Color::Black), Rank::Second);sourcepub fn n_backward(&self, color: Color, n: usize) -> Self
pub fn n_backward(&self, color: Color, n: usize) -> Self
sourcepub fn n_right_for(&self, color: Color, n: usize) -> Self
pub fn n_right_for(&self, color: Color, n: usize) -> Self
sourcepub fn n_left_for(&self, color: Color, n: usize) -> Self
pub fn n_left_for(&self, color: Color, n: usize) -> Self
sourcepub fn follow_direction(&self, direction: Direction) -> Self
pub fn follow_direction(&self, direction: Direction) -> Self
Trait Implementations
sourceimpl Ord for Square
impl Ord for Square
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<Square> for Square
impl PartialEq<Square> for Square
sourceimpl PartialOrd<Square> for Square
impl PartialOrd<Square> for Square
sourcefn partial_cmp(&self, other: &Square) -> Option<Ordering>
fn partial_cmp(&self, other: &Square) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl Copy for Square
impl Eq for Square
impl StructuralEq for Square
impl StructuralPartialEq for Square
Auto Trait Implementations
impl RefUnwindSafe for Square
impl Send for Square
impl Sync for Square
impl Unpin for Square
impl UnwindSafe for Square
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more