1 | use proc_macro2::TokenStream; |
2 | use quote::{ToTokens, TokenStreamExt}; |
3 | use syn::parse::{Parse, ParseStream, Result}; |
4 | use syn::{Attribute, Signature, Token, Visibility}; |
5 | |
6 | pub struct VerbatimFn { |
7 | pub attrs: Vec<Attribute>, |
8 | pub vis: Visibility, |
9 | pub defaultness: Option<Token![default]>, |
10 | pub sig: Signature, |
11 | pub semi_token: Token![;], |
12 | } |
13 | |
14 | impl Parse for VerbatimFn { |
15 | fn parse(input: ParseStream) -> Result<Self> { |
16 | Ok(VerbatimFn { |
17 | attrs: input.call(function:Attribute::parse_outer)?, |
18 | vis: input.parse()?, |
19 | defaultness: input.parse()?, |
20 | sig: input.parse()?, |
21 | semi_token: input.parse()?, |
22 | }) |
23 | } |
24 | } |
25 | |
26 | impl ToTokens for VerbatimFn { |
27 | fn to_tokens(&self, tokens: &mut TokenStream) { |
28 | tokens.append_all(&self.attrs); |
29 | self.vis.to_tokens(tokens); |
30 | self.defaultness.to_tokens(tokens); |
31 | self.sig.to_tokens(tokens); |
32 | self.semi_token.to_tokens(tokens); |
33 | } |
34 | } |
35 | |