#[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
Square
Every possible square on a chess board.
The order of enums is important, as Square::A1 as u8
corresponds to
that Square’s bit position in a bitboard.
WARNING: The exact ordering of enums is important for their discriminants.
Changing the discriminant of any variant is breaking.
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
pub fn from_idx<I: SquareIndexable>(indexable: I) -> Option<Square>
pub const fn iter() -> SquareIterator ⓘ
pub fn file(&self) -> File
pub fn rank(&self) -> Rank
Sourcepub const fn file_u8(&self) -> u8
pub const fn file_u8(&self) -> u8
Returns 0-based file (0,1,2,3,4,5,6,7), not 1-based chess file.
Sourcepub const fn rank_u8(&self) -> u8
pub const fn rank_u8(&self) -> u8
Returns 0-based rank (0,1,2,3,4,5,6,7), not 1-based chess rank.
Sourcepub fn increment_rank(&self) -> Option<Self>
pub fn increment_rank(&self) -> Option<Self>
Returns the Square with the Rank increased by one, “A3 -> A4”.
Sourcepub fn decrement_rank(&self) -> Option<Self>
pub fn decrement_rank(&self) -> Option<Self>
Returns the Square with the Rank decreased by one, “A3 -> A2”.
Trait Implementations§
Source§impl IntoIterator for Square
impl IntoIterator for Square
Source§impl Ord for Square
impl Ord for Square
Source§impl PartialOrd for Square
impl PartialOrd for Square
Source§impl SquareIndexable for Square
impl SquareIndexable for Square
Source§impl TryFrom<u8> for Square
Square enum variants cover all u8 values from 0-63 inclusive.
WARNING: Uses unsafe
.
impl TryFrom<u8> for Square
Square enum variants cover all u8 values from 0-63 inclusive.
WARNING: Uses unsafe
.
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