diff options
Diffstat (limited to 'varihappy-macros')
| -rw-r--r-- | varihappy-macros/Cargo.toml | 10 | ||||
| -rw-r--r-- | varihappy-macros/src/lib.rs | 15 |
2 files changed, 25 insertions, 0 deletions
diff --git a/varihappy-macros/Cargo.toml b/varihappy-macros/Cargo.toml new file mode 100644 index 0000000..968ce85 --- /dev/null +++ b/varihappy-macros/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "varihappy-macros" +version = "0.1.0" +edition = "2024" + +[lib] +proc-macro = true + +[dependencies] +proc_macros = "0.1.0" diff --git a/varihappy-macros/src/lib.rs b/varihappy-macros/src/lib.rs new file mode 100644 index 0000000..561962c --- /dev/null +++ b/varihappy-macros/src/lib.rs @@ -0,0 +1,15 @@ +use proc_macro::{Ident, Span, TokenStream, TokenTree}; + +#[proc_macro] +pub fn concat_idents(input: TokenStream) -> TokenStream { + let mut buffer = String::new(); + for token in input { + if let TokenTree::Ident(identifier) = token { + buffer.push_str(&identifier.to_string()); + } + } + + let mut stream = TokenStream::new(); + stream.extend([Ident::new(&buffer, Span::call_site())]); + stream +} |
