use quote::quote; use syn::{parse_macro_input, DeriveInput}; #[proc_macro_derive(RenderGraphLabel)] pub fn derive_render_graph_label(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as DeriveInput); let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); let type_ident = &input.ident; proc_macro::TokenStream::from(quote! { impl #impl_generics crate::render::graph::RenderGraphLabel for #type_ident #ty_generics #where_clause { fn rc_clone(&self) -> std::rc::Rc { std::rc::Rc::new(self.clone()) } /* fn as_dyn(&self) -> &dyn crate::render::graph::RenderGraphLabel { &self } fn as_partial_eq(&self) -> &dyn PartialEq { self } */ fn as_label_hash(&self) -> u64 { let tyid = ::std::any::TypeId::of::(); let mut s = ::std::hash::DefaultHasher::new(); ::std::hash::Hash::hash(&tyid, &mut s); ::std::hash::Hash::hash(self, &mut s); ::std::hash::Hasher::finish(&s) } } }) }