Skip to content

Instantly share code, notes, and snippets.

@bstrie
Created April 15, 2019 23:05
Show Gist options
  • Save bstrie/cba1ac0896c2f7b164f3d05e7838ce74 to your computer and use it in GitHub Desktop.
Save bstrie/cba1ac0896c2f7b164f3d05e7838ce74 to your computer and use it in GitHub Desktop.
Compiling countess v0.1.0 (C:\Users\Ben\code\rust\countess)
error[E0412]: cannot find type `ItemFn` in module `syn`
--> src\lib.rs:7:54
|
7 | let input = syn::parse_macro_input!(item as syn::ItemFn);
| ^^^^^^ not found in `syn`
error: aborting due to previous error
extern crate proc_macro;
use proc_macro::TokenStream;
use quote::quote;
#[proc_macro_attribute]
pub fn hello(attr: TokenStream, item: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(item as syn::ItemFn);
let name = &input.ident;
// Our input function is always equivalent to returning 42, right?
let result = quote! {
fn #name() -> u32 { 42 }
};
result.into()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment