Expand description
The gridly prelude includes all traits and common structs.
Note that the prelude does not include the single-character shorthand functions, so as not to pollute your namespace with single-character identifiers on a bulk import.
Re-exports§
pub use crate::direction::Down;pub use crate::direction::Left;pub use crate::direction::Right;pub use crate::direction::Up;pub use crate::rotation::Anticlockwise;pub use crate::rotation::Clockwise;
Structs§
- Column
- A
column
component of a
Location. SeeComponentfor details. - Columns
- A
columns
component of a
Vector - Location
- A location on a grid. A location is the primary indexing type for a
Grid, and represents a single cell on that grid. It is comprised of a
Rowand aColumn. Increasing row count downward and increasing columns count rightward. - Location
Range - A range over
Locations in a givenRoworColumn. - Row
- A
row
component of a
Location. SeeComponentfor details. - Rows
- A
rows
component of a
Vector - Vector
- A measurement of distance between two
Locations
Enums§
- Bounds
Error - An out-of-bounds error for a Location on a grid
- Direction
- The four cardinal directions:
Up,Down,Left, andRight.Directionimplements a number of simple helper methods. It also implementsVectorLike, which allows it to be used in contexts where aVectorcan be used as a unit vector in the given direction (for example, with Vector arithmetic). - Rotation
- The 4 cardinal rotations:
None(no rotation),Flip,Clockwise, andAnticlockwise. These rotations support basic arithmetic operations with themselves (sums, multiplication by a factor, etc) and can be applied toDirectionandVector.
Statics§
- DIAGONAL_
ADJACENCIES - This array contains unit vectors associated with the 4 diagonal directions. It is intended to allow for easy iteration over diagonally adjacent locations. The order of the vectors is unspecified and should not be relied upon.
- EACH_
DIRECTION - This array contains each direction; it is intended to allow for easy iteration over adjacent locations. The order of the directions is left unspecified and should not be relied upon.
- ORTHOGONAL_
ADJACENCIES - This array contains unit vectors associated with the 4 orthogonally adjacent directions. It is intended to allow for easy iteration over orthogonally adjacent locations. The order of the vectors is unspecified and should not be relied upon.
- TOUCHING_
ADJACENCIES - This array contains unit vectors associated with the 8 adjacent directions. It is intended to allow for easy iteration over all locations that touch a center location (for instance, when scanning adjacencies in an implementation of Conway’s Game of Life). The order of the vectors is unspecified and should not be relied upon.
Traits§
- Grid
- Base Reader trait for grids. This trait provides the grid’s cell type,
Item, and an unsafe getter method for fetching a cell at a bounds-checked location. It uses this unsafe getter, plusGridBoundsbased bounds-checking, to provide a comprehensive and safe interface for reading and iterating over elements in a grid. - Grid
Bounds - Grid trait implementing grid sizes and boundary checking.
- GridMut
- Grid
Setter - Setter trait for grids. Allows setting and replacing elements in the grid. Implementors should implement the unsafe setter and replacer methods. This trait then provides implementations of safe, bounds-checked setters.
- Location
Component - A component of a
Location, which may be either aRowor aColumn. It is effectively an index into a given row or column of a grid; for instance, aRowcan index a row in a grid. - Location
Like - This trait covers structs that act like a
Location, such as tuples. See theLocationdocumentation for more details. - Vector
Component - A
RowsorColumnscomponent of aVector - Vector
Like VectorLikeis implemented for types that can be used as a vector. They can participate in vector arithmetic, comparison, and other vector oprations.