Add Dir group consts

This commit is contained in:
Tad Hardesty 2019-11-17 17:53:19 -08:00
parent 25ff4c2b78
commit ac626acab5
2 changed files with 5 additions and 1 deletions

View file

@ -20,6 +20,10 @@ pub enum Dir {
}
impl Dir {
pub const CARDINALS: &'static [Dir] = &[Dir::North, Dir::South, Dir::East, Dir::West];
pub const DIAGONALS: &'static [Dir] = &[Dir::Northeast, Dir::Northwest, Dir::Southeast, Dir::Southwest];
pub const ALL: &'static [Dir] = &[Dir::North, Dir::South, Dir::East, Dir::West, Dir::Northeast, Dir::Northwest, Dir::Southeast, Dir::Southwest];
/// Attempt to build a direction from its integer representation.
pub fn from_int(int: i32) -> Option<Dir> {
Some(match int {

View file

@ -79,7 +79,7 @@ fn calculate_adjacencies(objtree: &ObjectTree, neighborhood: &Neighborhood, atom
}
};
for &dir in &[Dir::South, Dir::North, Dir::East, Dir::West] {
for &dir in Dir::CARDINALS {
adjacencies |= check_one(dir, 1 << dir.to_int());
}