chesspos 0.2.0

Basic structs for representing chess squares
Documentation
  • Coverage
  • 35.04%
    48 out of 137 items documented23 out of 30 items with examples
  • Size
  • Source code size: 43.56 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.74 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • ijagberg/chesspos
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ijagberg

chesspos

Useful structs and constants for representing chess board positions.

Position

The main point of this library is the Position struct, which represents a position on a chess board.

use chesspos::prelude::*;

// each position is defined as a const,
// and can be referred to like this:
let a4 = A4;

// the Position struct has various methods
// useful for chess programming
assert_eq!(B4, a4.right().unwrap()); // get the position to the right of A4
assert!(a4.left().is_none()); // no position to the left of A4

Rank & File

There's also a Rank and a File enum, which is useful for traversal and iteration.

use chesspos::prelude::*;

assert_eq!(File::G.iter().collect(), vec![G1, G2, G3, G4, G5, G6, G7, G8]);
assert_eq!(Rank::Two.iter().collect(), vec![A2, B2, C2, D2, E2, F2, G2, H2]);