diff options
author | HampusM <hampus@hampusmat.com> | 2023-01-30 21:29:21 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-01-30 21:29:21 +0100 |
commit | 178267c701c233542078c09fe6b19802f9642dbd (patch) | |
tree | 3d3010806f6509c062ca86dbbbe9c3a6cd2fe547 /macros/src/util/mod.rs | |
parent | 17ca46e95af38a914197958bbcc1e759865b6005 (diff) |
feat: improve macro error messages
Diffstat (limited to 'macros/src/util/mod.rs')
-rw-r--r-- | macros/src/util/mod.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/macros/src/util/mod.rs b/macros/src/util/mod.rs index 0705853..d3edb67 100644 --- a/macros/src/util/mod.rs +++ b/macros/src/util/mod.rs @@ -1,4 +1,27 @@ +pub mod error; pub mod item_impl; pub mod iterator_ext; pub mod string; pub mod syn_path; + +macro_rules! to_option { + ($($tokens: tt)+) => { + Some($($tokens)+) + }; + + () => { + None + }; +} + +macro_rules! or { + (($($tokens: tt)+) else ($($default: tt)*)) => { + $($tokens)* + }; + + (() else ($($default: tt)*)) => { + $($default)* + }; +} + +pub(crate) use {or, to_option}; |