FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Do not use generic param defaults in `impl`s by rmartinho · Pull Request #74 · yewstack/implicit-clone · GitHub

Do not use generic param defaults in impls - #74

Open
rmartinho wants to merge 1 commit into
yewstack:mainfrom
rmartinho:dont-use-generic-defaults
Open

Do not use generic param defaults in impls#74
rmartinho wants to merge 1 commit into
yewstack:mainfrom
rmartinho:dont-use-generic-defaults

Conversation

Copy link
Copy Markdown

This will become an error in the future, and the defaults in impl are ignored anyway so it makes no sense to preserve them in the generated impl.

kirillsemyonkin commented Aug 21, 2025
edited
Loading

Copy link
Copy Markdown
Collaborator

ngl first time looking into this derive code, it is kinda weird. could just rewrite to

#[proc_macro_derive(ImplicitClone)]
pub fn derive_implicit_clone(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
    let mut input = syn::parse_macro_input!(item as syn::DeriveInput);
    input
        .generics
        .type_params_mut()
        .for_each(|type_param| type_param.bounds.push(syn::parse_quote! { ::implicit_clone::ImplicitClone }));

    let syn::DeriveInput {
        ident, generics, ..
    } = input;
    let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
    let res = quote! {
        impl #impl_generics ::implicit_clone::ImplicitClone for #ident #ty_generics #where_clause {}
    };
    res.into()
}

this way we just add bounds, and rest syn will figure out on its own

Copy link
Copy Markdown
Author

I'm not super familiar with writing derive macros, so I tried to change as little as necessary.

I will try your implementation later and update the PR if there are no issues.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL