sqrid
sqrid provides square grid coordinates and related operations, in a single-file create, with no dependencies.
Usage
The Qa type represents an absolute position in a square
grid. The type itself receives the height and width of the grid as
const generic parameter.
We should usually create a type alias for the grid size we are using:
use sqrid;
type Qa = Qa;
Creating Qa instances
We can get Qa instances by:
- Using one of the const associated items:
type Qa = Qa; const MyFirst : Qa = FIRST; const MyLast : Qa = LAST; - Using
try_fromwith a(i16, i16)tuple or a tuple reference:use TryFrom; use Error; type Qa = Qa; const MyFirst : Qa = FIRST; - Calling
Qa::new, which checks the bounds in const contexts:
The following, for instance, doesn't compile:type Qa = Qa; const MY_FIRST : Qa = ;type Qa = Qa; const MY_FIRST : Qa = ;