From b8808fe47b8b2abd05989c7b1faabb29fabc0c07 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Tue, 11 Nov 2025 20:12:11 -0500 Subject: dungeon: rewrite const_pos! --- dungeon/src/pos.rs | 21 +++++++++------------ 1 file 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 -- cgit v1.2.3-freya