summaryrefslogtreecommitdiff
path: root/glfw/src/util.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-03-06 22:15:33 +0100
committerHampusM <hampus@hampusmat.com>2024-03-06 22:15:41 +0100
commit251beb34720d2e7d60ceaddc811a65f52f15bdbd (patch)
tree7342c483661d3dc2f229097a15a41532c333e3c5 /glfw/src/util.rs
parentb9668a6ba06af650eab5c77c78a487556af20a6b (diff)
feat(glfw): add setting key callback
Diffstat (limited to 'glfw/src/util.rs')
-rw-r--r--glfw/src/util.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/glfw/src/util.rs b/glfw/src/util.rs
index f77aaf8..98dcb9b 100644
--- a/glfw/src/util.rs
+++ b/glfw/src/util.rs
@@ -8,3 +8,34 @@ pub fn is_main_thread() -> bool
ttid == pid
}
+
+macro_rules! enum_from_repr {
+ (
+ #[repr($repr: ident)]
+ $(#[$attr: meta])*
+ $visibility: vis enum $name: ident
+ {
+ $($variant: ident = $raw: path,)*
+ }
+ ) => {
+ $(#[$attr])*
+ #[repr($repr)]
+ $visibility enum $name
+ {
+ $($variant = $raw,)*
+ }
+
+ impl $name
+ {
+ fn from_repr(repr: $repr) -> Option<Self>
+ {
+ match repr {
+ $($raw => Some(Self::$variant),)*
+ _ => None
+ }
+ }
+ }
+ };
+}
+
+pub(crate) use enum_from_repr;