diff options
author | HampusM <hampus@hampusmat.com> | 2022-10-15 18:40:20 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-10-15 18:40:20 +0200 |
commit | 740ef47d49e02ae2f2184f4c347d8eba8aee38fd (patch) | |
tree | 4a9cbf8f067b6e99f1f95dab774216d804829051 /macros/src/injectable/named_attr_input.rs | |
parent | fdbd28fc18a5d2019132413b6699ff7691968fc2 (diff) |
refactor: improve internals of macros & add unit tests
Diffstat (limited to 'macros/src/injectable/named_attr_input.rs')
-rw-r--r-- | macros/src/injectable/named_attr_input.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/macros/src/injectable/named_attr_input.rs b/macros/src/injectable/named_attr_input.rs index 5f7123c..eaa9dbf 100644 --- a/macros/src/injectable/named_attr_input.rs +++ b/macros/src/injectable/named_attr_input.rs @@ -1,8 +1,11 @@ +use quote::ToTokens; use syn::parse::Parse; +use syn::token::Paren; use syn::{parenthesized, LitStr}; pub struct NamedAttrInput { + pub paren: Paren, pub name: LitStr, } @@ -12,10 +15,22 @@ impl Parse for NamedAttrInput { let content; - parenthesized!(content in input); + let paren = parenthesized!(content in input); Ok(Self { + paren, name: content.parse()?, }) } } + +impl ToTokens for NamedAttrInput +{ + fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) + { + self.paren + .surround(&mut self.name.to_token_stream(), |stream| { + stream.to_tokens(tokens); + }); + } +} |