From 770f14609849552d965b4e9101bfb5c0870c08d0 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Mon, 8 Jul 2019 22:31:41 +0200 Subject: Command filtering to avoid wasting the selects --- src/geometry/direction.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src/geometry/direction.rs') diff --git a/src/geometry/direction.rs b/src/geometry/direction.rs index 737bd00..d3f3b20 100644 --- a/src/geometry/direction.rs +++ b/src/geometry/direction.rs @@ -1,5 +1,5 @@ -use std::fmt; use crate::geometry::vec::Vec2d; +use std::fmt; #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Direction { @@ -54,17 +54,14 @@ impl Direction { } } - pub fn all() -> [Direction; 8] { - use Direction::*; - [ - North, - NorthEast, - East, - SouthEast, - South, - SouthWest, - West, - NorthWest, - ] - } + pub const ALL: [Direction; 8] = [ + Direction::North, + Direction::NorthEast, + Direction::East, + Direction::SouthEast, + Direction::South, + Direction::SouthWest, + Direction::West, + Direction::NorthWest, + ]; } -- cgit v1.2.3