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

FromVariant derive has incorrect type on fields field #200

Closed
mfreeborn opened this issue Sep 17, 2022 · 2 comments
Closed

FromVariant derive has incorrect type on fields field #200

mfreeborn opened this issue Sep 17, 2022 · 2 comments

Comments

@mfreeborn
Copy link

Looking at the documentation here, it suggests that the type for the fields field is Option<darling::ast::Fields<__>>.

Having just tried to implement this (using darling v0.14.1), I get an error stating that the true type is actually darling::ast::Fields<_>.

Testing it on a plain enum without tuple/field variants, fields returns an empty vector. I think it would be better if the behaviour was as per the documentation, and that non-tuple/field variants return None and others return Some(*at least one field*).

I also think it would be clear in the docs to mention that darling::ast::Fields<_> something which implements FromField e.g. darling::ast::Fields<T: impl darling::FromField> just to save a bit of digging around in the documentation/chasing error messages.

@TedDriggs
Copy link
Owner

Changing it to be an Option would break lots of existing code, so I'll update the docs to accurately capture the true type.

@mfreeborn
Copy link
Author

That's much clearer, thanks!

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

2 participants