#[repr(u8)]pub enum Square {
Show 64 variants
A1 = 0,
B1 = 1,
C1 = 2,
D1 = 3,
E1 = 4,
F1 = 5,
G1 = 6,
H1 = 7,
A2 = 8,
B2 = 9,
C2 = 10,
D2 = 11,
E2 = 12,
F2 = 13,
G2 = 14,
H2 = 15,
A3 = 16,
B3 = 17,
C3 = 18,
D3 = 19,
E3 = 20,
F3 = 21,
G3 = 22,
H3 = 23,
A4 = 24,
B4 = 25,
C4 = 26,
D4 = 27,
E4 = 28,
F4 = 29,
G4 = 30,
H4 = 31,
A5 = 32,
B5 = 33,
C5 = 34,
D5 = 35,
E5 = 36,
F5 = 37,
G5 = 38,
H5 = 39,
A6 = 40,
B6 = 41,
C6 = 42,
D6 = 43,
E6 = 44,
F6 = 45,
G6 = 46,
H6 = 47,
A7 = 48,
B7 = 49,
C7 = 50,
D7 = 51,
E7 = 52,
F7 = 53,
G7 = 54,
H7 = 55,
A8 = 56,
B8 = 57,
C8 = 58,
D8 = 59,
E8 = 60,
F8 = 61,
G8 = 62,
H8 = 63,
}Expand description
Represent a square on the chess board.
Variants§
A1 = 0
B1 = 1
C1 = 2
D1 = 3
E1 = 4
F1 = 5
G1 = 6
H1 = 7
A2 = 8
B2 = 9
C2 = 10
D2 = 11
E2 = 12
F2 = 13
G2 = 14
H2 = 15
A3 = 16
B3 = 17
C3 = 18
D3 = 19
E3 = 20
F3 = 21
G3 = 22
H3 = 23
A4 = 24
B4 = 25
C4 = 26
D4 = 27
E4 = 28
F4 = 29
G4 = 30
H4 = 31
A5 = 32
B5 = 33
C5 = 34
D5 = 35
E5 = 36
F5 = 37
G5 = 38
H5 = 39
A6 = 40
B6 = 41
C6 = 42
D6 = 43
E6 = 44
F6 = 45
G6 = 46
H6 = 47
A7 = 48
B7 = 49
C7 = 50
D7 = 51
E7 = 52
F7 = 53
G7 = 54
H7 = 55
A8 = 56
B8 = 57
C8 = 58
D8 = 59
E8 = 60
F8 = 61
G8 = 62
H8 = 63
Implementations§
Source§impl 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§
Source§impl Ord for Square
impl Ord for Square
Source§impl PartialOrd for Square
impl PartialOrd for Square
impl Copy for Square
impl Eq for Square
impl StructuralPartialEq for Square
Auto Trait Implementations§
impl Freeze for Square
impl RefUnwindSafe for Square
impl Send for Square
impl Sync for Square
impl Unpin for Square
impl UnwindSafe for Square
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more