]> git.proxmox.com Git - rustc.git/blob - src/doc/book/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/src/lib.rs
New upstream version 1.49.0+dfsg1
[rustc.git] / src / doc / book / listings / ch19-advanced-features / listing-19-31 / hello_macro / hello_macro_derive / src / lib.rs
1 extern crate proc_macro;
2
3 use proc_macro::TokenStream;
4 use quote::quote;
5 use syn;
6
7 #[proc_macro_derive(HelloMacro)]
8 pub fn hello_macro_derive(input: TokenStream) -> TokenStream {
9 // Construct a representation of Rust code as a syntax tree
10 // that we can manipulate
11 let ast = syn::parse(input).unwrap();
12
13 // Build the trait implementation
14 impl_hello_macro(&ast)
15 }