lattice_graph/lib.rs
1/*!
2Extention library for [petgraph](https://crates.io/crates/petgraph).
3This adds a specialized graph for lattice (or grid) based graph structures for petgraph.
4This probides a smaller and faster graph than the general purpose `petgraph::Graph` struct.
5It can be used for path finding in tilemap based game.
6This is for developing game, but it can be used for other purposes as well.
7
8# features
9## const-generic-wrap
10Use [`const-generic-wrap`](`const_generic_wrap`) to make it possible to make some
11[`Shape`](`crate::lattice_abstract::shapes::Shape`) to be ZST.
12
13This needs const generics (rustc >= 1.51) to use.
14This is enabled by default, so if you want to use this crate with rustc < 1.51,
15set default-features as false.
16
17## hex2d
18Use [`hex2d`](`hex2d`) as a
19[`shapes::Coordinate`](`crate::lattice_abstract::shapes::Coordinate`).
20See [`hex::hex2d`] for details.
21*/
22
23#![allow(clippy::missing_safety_doc)]
24
25// fixedvec2d module replaced with ndarray
26pub use ndarray::{Array2, ArrayView2, ArrayViewMut2};
27pub mod square;
28pub use square::SquareGraph;
29pub mod hex;
30pub mod lattice_abstract;
31
32#[inline(always)]
33pub(crate) unsafe fn unreachable_debug_checked<T>() -> T {
34 if cfg!(debug_assertions) {
35 unreachable!()
36 } else {
37 core::hint::unreachable_unchecked()
38 }
39}