Created
April 15, 2019 23:05
-
-
Save bstrie/cba1ac0896c2f7b164f3d05e7838ce74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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