diff options
Diffstat (limited to 'dungeon')
| -rw-r--r-- | dungeon/src/pos.rs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/dungeon/src/pos.rs b/dungeon/src/pos.rs index b7a977c..59daaa2 100644 --- a/dungeon/src/pos.rs +++ b/dungeon/src/pos.rs @@ -32,18 +32,15 @@ macro_rules! try_from { #[macro_export] macro_rules! const_pos { - ($x:expr, $y:expr) => {{ - assert!( - $x < $crate::map::MAP_SIZE, - "Positions must be smaller then MAP_SIZE" - ); - assert!( - $y < $crate::map::MAP_SIZE, - "Positions must be smaller then MAP_SIZE" - ); - const CONST_POS: Pos = unsafe { Pos::new_unchecked($x, $y) }; - CONST_POS - }}; + ($x:expr, $y:expr) => { + const { + const X: u16 = $x; + const Y: u16 = $y; + assert!(X < $crate::map::MAP_SIZE, "X must be smaller then MAP_SIZE"); + assert!(Y < $crate::map::MAP_SIZE, "Y must be smaller then MAP_SIZE"); + unsafe { $crate::pos::Pos::new_unchecked(X, Y) } + } + }; } /// The `Direction` type represents a direction an entity |