Skip to content

Commit

Permalink
Derive macro should also work on enums (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
cecton authored Nov 11, 2023
1 parent 8714ccf commit 085211b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions implicit-clone-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use quote::quote;

#[proc_macro_derive(ImplicitClone)]
pub fn derive_implicit_clone(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
let syn::ItemStruct {
let syn::DeriveInput {
ident, generics, ..
} = syn::parse_macro_input!(item as syn::ItemStruct);
} = syn::parse_macro_input!(item as syn::DeriveInput);
let (_impl_generics, ty_generics, where_clause) = generics.split_for_impl();
let generics = generics
.params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ struct StructWithGenerics<T>(T);
#[derive(Clone, ImplicitClone)]
struct StructWithGenericsWithBounds<T: PartialEq>(T);

#[derive(Clone, ImplicitClone)]
enum ExampleEnum {}

#[derive(Clone, ImplicitClone)]
enum EnumWithGenerics<T> {
Variant(T),
}

fn main() {
let _ = ImplicitClone::implicit_clone(&ExampleStruct);
}

0 comments on commit 085211b

Please sign in to comment.