-
Notifications
You must be signed in to change notification settings - Fork 68
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
Accept from_* methods as #[darling(...)] fields #320
Labels
Comments
TedDriggs
added a commit
that referenced
this issue
Jan 22, 2025
This allows overriding how FromMeta-deriving types handle shorthand declarations or being absent altogether. Previously, this was done using `with` on each field where the type was consumed, but that could cause attribute sprawl or inconsistent behavior when consuming the type. This commit includes validations to avoid conflicts for unit structs, newtype structs, and enums that use the `word` variant-level attribute. Fixes #320
TedDriggs
added a commit
that referenced
this issue
Jan 22, 2025
This allows overriding how FromMeta-deriving types handle shorthand declarations or being absent altogether. Previously, this was done using `with` on each field where the type was consumed, but that could cause attribute sprawl or inconsistent behavior when consuming the type. This commit includes validations to avoid conflicts for unit structs, newtype structs, and enums that use the `word` variant-level attribute. Fixes #320
TedDriggs
added a commit
that referenced
this issue
Jan 22, 2025
This allows overriding how FromMeta-deriving types handle shorthand declarations or being absent altogether. Previously, this was done using `with` on each field where the type was consumed, but that could cause attribute sprawl or inconsistent behavior when consuming the type. This commit includes validations to avoid conflicts for unit structs, newtype structs, and enums that use the `word` variant-level attribute. Fixes #320
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's currently impossible to have a struct with a derived
FromMeta
impl that has custom behavior in thefrom_word
orfrom_none
cases. The only workaround is to usewith
on every field of that type, which is tiresome.Based on the discussion in #313, this proposal would allow the deriving struct to specify a path (or closure) that replaces the body of the corresponding method.
This will require some validation to ensure these options aren't conflicting with generated impls; for example,
from_word
cannot be used with enums whereword
is in use.Additionally, this will require new documentation and examples.
The text was updated successfully, but these errors were encountered: