Skip to content
Snippets Groups Projects
Commit 6272e89b authored by Per Lindgren's avatar Per Lindgren
Browse files

polish

parent d5be3391
Branches master
No related tags found
No related merge requests found
...@@ -3,27 +3,31 @@ extern crate proc_macro; ...@@ -3,27 +3,31 @@ extern crate proc_macro;
use proc_macro::TokenStream; use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2; use proc_macro2::TokenStream as TokenStream2;
use syn::{ use syn::{
braced, parenthesized, // braced, parenthesized,
parse::{self, Parse, ParseStream, Parser}, // parse::{self, Parse, ParseStream, Parser},
token::Brace, parse,
Ident, Item, LitInt, Token, // token::Brace,
// Ident,
Item,
// LitInt,
// Token,
}; };
#[proc_macro_attribute] #[proc_macro_attribute]
pub fn my_attribute(args: TokenStream, input: TokenStream) -> TokenStream { pub fn my_attribute(args: TokenStream, input: TokenStream) -> TokenStream {
eprintln!("--- args {:?}", args); // eprintln!("--- args {:?}", args);
eprintln!("--- input {:?}", input); // eprintln!("--- input {:?}", input);
let r = app(args.into(), input.into()); let r = app(args.into(), input.into());
r.unwrap() r.unwrap()
} }
fn app(args: TokenStream2, input: TokenStream2) -> parse::Result<TokenStream> { fn app(_args: TokenStream2, input: TokenStream2) -> parse::Result<TokenStream> {
match syn::parse2(input.clone())? { match syn::parse2(input.clone())? {
Item::Fn(f) => { Item::Fn(_f) => {
eprintln!("we found a function"); eprintln!("we found a function");
} }
Item::Struct(s) => { Item::Struct(_s) => {
eprintln!("we found a struct"); eprintln!("we found a struct");
} }
_ => unimplemented!("case not covered"), _ => unimplemented!("case not covered"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment