]> git.nega.tv - josh/narcissus/commitdiff
narcissus-core: Add user-defined type to `flags_def` macro
authorJoshua Simmons <josh@nega.tv>
Sun, 5 May 2024 14:20:25 +0000 (16:20 +0200)
committerJoshua Simmons <josh@nega.tv>
Sun, 5 May 2024 14:38:04 +0000 (16:38 +0200)
engine/narcissus-core/src/lib.rs

index 40e8169f228a6994babe006517fbb6426d1aa05b..3372d6cb02872ce32098d4924a5ef03aafaddfba 100644 (file)
@@ -118,17 +118,20 @@ macro_rules! thread_token_def {
 #[macro_export]
 macro_rules! flags_def {
     ($name:ident) => {
+        flags_def!($name, u32);
+    };
+    ($name:ident, $ty:ty) => {
         #[derive(PartialEq, Hash, Debug)]
-        pub struct $name(u32);
+        pub struct $name($ty);
 
         impl $name {
             #[inline]
-            pub fn from_raw(value: u32) -> Self {
+            pub fn from_raw(value: $ty) -> Self {
                 Self(value)
             }
 
             #[inline]
-            pub fn as_raw(self) -> u32 {
+            pub fn as_raw(self) -> $ty {
                 self.0
             }