mod content_hash;
extern crate proc_macro;
use quote::quote;
use syn::DeriveInput;
use syn::parse_macro_input;
#[proc_macro_derive(ContentHash)]
pub fn derive_content_hash(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(input as DeriveInput);
let name = &input.ident;
let hash_impl = content_hash::generate_hash_impl(&input.data);
let generics = content_hash::add_trait_bounds(input.generics);
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
let expanded = quote! {
#[automatically_derived]
impl #impl_generics ::jj_lib::content_hash::ContentHash for #name #ty_generics
#where_clause {
fn hash(&self, state: &mut impl ::jj_lib::content_hash::DigestUpdate) {
#hash_impl
}
}
};
expanded.into()
}