1 #![feature(proc_macro_diagnostic)] 2 3 #[macro_use] extern crate quote; 4 extern crate devise; 5 extern crate proc_macro; 6 7 use proc_macro::TokenStream; 8 use devise::*; 9 10 #[proc_macro_derive(Example0)] derive_generic_example(input: TokenStream) -> TokenStream11pub fn derive_generic_example(input: TokenStream) -> TokenStream { 12 DeriveGenerator::build_for(input, quote!(impl<T> Example0<T>)) 13 .generic_support(GenericSupport::All) 14 .data_support(DataSupport::All) 15 .replace_generic(0, 0) 16 .function(|_, _| quote! { 17 fn example(self) -> T { unimplemented!() } 18 }) 19 .to_tokens() 20 } 21 22 #[proc_macro_derive(Example0usize)] derive_concrete_generic(input: TokenStream) -> TokenStream23pub fn derive_concrete_generic(input: TokenStream) -> TokenStream { 24 DeriveGenerator::build_for(input, quote!(impl Example0<usize>)) 25 .generic_support(GenericSupport::All) 26 .data_support(DataSupport::All) 27 .function(|_, _| quote! { 28 fn example(self) -> usize { unimplemented!() } 29 }) 30 .to_tokens() 31 } 32