Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using #[darling(with = ...)] should somehow work for fields whose types don't impl FromMeta #305

Open
TedDriggs opened this issue Sep 5, 2024 · 0 comments

Comments

@TedDriggs
Copy link
Owner

Right now, the following code doesn't work:

fn demo(meta: &syn::Meta) -> darling::Result<Vec<usize>> {
    // doesn't matter
}

#[derive(FromDeriveInput)]
pub struct Example {
    #[darling(with = demo)]
    field: Vec<usize>
}

This fails to compile because Vec<usize> does not impl FromMeta.

The problem is the generated code for handling a missing field, which attempts to call <Vec<usize> as FromMeta>::from_none; that doesn't exist, and so the code doesn't compile. Adding a default for the field or struct works fine, but that shouldn't be required to make this work.

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

No branches or pull requests

1 participant