1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#![no_std]
pub mod direction;
pub mod grid;
pub mod location;
pub mod range;
pub mod rotation;
pub mod vector;
/// The shorthand module includes quick single-character shorthand constructors
/// for the common gridly types ([`Row`][location::Row],
/// [`Column`][location::Column], [`Vector`][vector::Vector], and
/// [`Location`][location::Location]).
///
/// These are not included in the [`prelude`][prelude] because we don't want a
/// bulk import to unexpectedly add a bunch of single-character names to the
/// namespace.
pub mod shorthand {
use crate::location::{Column, Location, Row};
use crate::vector::{Columns, Rows, Vector};
// TODO: make these shorthands smart enough to be either `Row` or `Rows` using
// generics. Perhaps they can implement both kinds of component?
/// Shorthand to create a [`Row`].
#[allow(non_snake_case)]
#[inline(always)]
pub fn R(row: impl Into<Row>) -> Row {
row.into()
}
/// Shorthand to create a [`Column`].
#[allow(non_snake_case)]
#[inline(always)]
pub fn C(column: impl Into<Column>) -> Column {
column.into()
}
/// Shorthand to create a [`Vector`].
#[allow(non_snake_case)]
#[inline(always)]
pub fn V(rows: impl Into<Rows>, columns: impl Into<Columns>) -> Vector {
Vector::new(rows, columns)
}
/// Shorthand to create a [`Location`].
#[allow(non_snake_case)]
#[inline(always)]
pub fn L(row: impl Into<Row>, column: impl Into<Column>) -> Location {
Location::new(row, column)
}
}
/// 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.
pub mod prelude {
#[doc(inline)]
pub use crate::direction::{Direction, Down, Left, Right, Up, EACH_DIRECTION};
#[doc(inline)]
pub use crate::grid::{BoundsError, Grid, GridBounds, GridMut, GridSetter};
#[doc(inline)]
pub use crate::location::{
Column, Component as LocationComponent, Location, LocationLike, Row,
};
#[doc(inline)]
pub use crate::range::{ColumnRange, ColumnRangeError, LocationRange, RowRange, RowRangeError};
#[doc(inline)]
pub use crate::vector::{
Columns, Component as VectorComponent, Rows, Vector, VectorLike, DIAGONAL_ADJACENCIES,
ORTHOGONAL_ADJACENCIES, TOUCHING_ADJACENCIES,
};
#[doc(inline)]
pub use crate::rotation::{Anticlockwise, Clockwise, Rotation};
}