#[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
Represents a single square on the 8×8 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 const unsafe fn from_mask(mask: u64) -> Self
pub const unsafe fn from_mask(mask: u64) -> Self
Converts a mask to a square.
§Safety
The mask must have exactly one bit set in positions 0-63. Passing zero, multiple bits, or a bit >= 64 causes undefined behavior.
Sourcepub const unsafe fn from_u8(index: u8) -> Self
pub const unsafe fn from_u8(index: u8) -> Self
Converts an index to a square.
§Safety
The index must be in the range 0..64. Passing an index >= 64 causes undefined behavior.
Use try_from_u8 for a safe alternative.
Sourcepub const unsafe fn from_usize(index: usize) -> Self
pub const unsafe fn from_usize(index: usize) -> Self
Converts an array index to a square.
§Safety
The index must be in the range 0..64. Passing an index >= 64 causes undefined behavior.
Use try_from_usize for a safe alternative.
Sourcepub const fn manhattan(&self, other: Self) -> u8
pub const fn manhattan(&self, other: Self) -> u8
Returns the manhattan distance between two squares.
Sourcepub const unsafe fn from_row_column(row: u8, column: u8) -> Self
pub const unsafe fn from_row_column(row: u8, column: u8) -> Self
Creates a square from row and column indices.
Row 0 is rank 1, row 7 is rank 8. Column 0 is file a, column 7 is file h.
§Safety
Both row and column must be in the range 0..8. Passing row >= 8 or column >= 8 causes undefined behavior.
Sourcepub const fn try_from_u8(index: u8) -> Option<Self>
pub const fn try_from_u8(index: u8) -> Option<Self>
Tries to convert an index to a square.
Returns Some(Square) if the index is in range [0, 63], otherwise None.
Sourcepub const fn try_from_usize(index: usize) -> Option<Self>
pub const fn try_from_usize(index: usize) -> Option<Self>
Tries to convert an index to a square.
Returns Some(Square) if the index is in range [0, 63], otherwise None.
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
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>
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>
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