const_identify_derive/
lib.rs1use proc_macro::TokenStream;
2use quote::quote;
3use syn::{parse_macro_input, DeriveInput};
4
5#[proc_macro_derive(ConstIdentify)]
6pub fn derive_const_identify(input: TokenStream) -> TokenStream {
7 let DeriveInput {
9 ident, generics, ..
10 } = parse_macro_input!(input);
11
12 let (implgen, typegen, wheregen) = generics.split_for_impl();
14
15 let output = quote! {
17 unsafe impl #implgen ::const_identify::ConstIdentify for #ident #typegen #wheregen {
18 const CONST_ID: ::const_identify::ConstId = ::const_identify::ConstId::generate(
19 concat!(
20 module_path!(), "::", stringify!(#ident),
21 ":", file!(), ":", line!(), ":", column!()
22 )
23 );
24 }
25 };
26
27 output.into()
29}