Module hexe_core::square
[−]
[src]
A chess board square and its components.
A chess board is comprised of sixty-four squares ranging from A1 through H8. Each square has two components:
- File: a column represented by a letter from A through F
- Rank: a row represented by a number from 1 through 8
Examples
Basic usage:
use hexe_core::square::{Square, File, Rank}; let f = File::B; let r = Rank::Seven; let sq = Square::B7; assert_eq!(sq, Square::new(f, r));
Square
is an enum
so that we can safely and conveniently index into
tables of sixty-four elements. Because the optimizer knows that the index
will never be greater than 64, the bounds check gets removed, thus
making lookups fast.
static TABLE: [T; 64] = [ /* ... */ ]; pub fn get_value(sq: Square) -> T { // Will never panic TABLE[sq as usize] }
Structs
FromStrError |
The error returned when |
Enums
File |
A file (or column) for a chess board. |
Rank |
A rank (or row) for a chess board. |
Square |
A square on a chess board. |