partial_eq_dyn_derive 0.1.0

Derives for PartialEq on structs and enums with trait objects
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use proc_macro2::TokenStream;
use quote::quote;
use syn::DeriveInput;

pub fn parse(input: TokenStream) -> DeriveInput {
    syn::parse2(input).expect("The Item is supposed to be a Struct or Enum")
}

pub fn impl_as_any(ast: &syn::DeriveInput) -> TokenStream {
    let item_name = &ast.ident;
    quote! {
        impl  partial_eq_dyn::AsAny for #item_name {
            fn as_any(&self) -> &dyn std::any::Any {
                self
            }
        }
    }
}