Expand description
Trait to implement a type that can be used as a grid cell with pparsing and display functionalities.
The trait itself is empty but requires to implement TryFrom<char>.
This trait is most useful by using the derive macro and specifying assiciated char values.
use game_grid::*;
#[derive(GridCell, Copy, Clone, Debug, PartialEq, Eq, Default)]
enum Cell {
// Wall cells are represented by '#'.
#[cell('#')]
Wall,
// Empty cells are represented by both ' ' and '.', the former will be used for display.
// A default value can be used by some Grid functionalities.
#[cell(' '|'.')]
#[default]
Empty,
#[cell('o')]
Food,
// It is also possible to provide a range, the actual character can be captured.
#[cell('A'..='Z')]
Player(char),
}