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

Allow custom from_word and from_none behaviors in derived FromMeta impls #323

Merged
merged 3 commits into from
Jan 22, 2025

Conversation

TedDriggs
Copy link
Owner

Fixes #320

README.md Show resolved Hide resolved
core/src/codegen/from_meta_impl.rs Outdated Show resolved Hide resolved
core/src/options/input_field.rs Outdated Show resolved Hide resolved
tests/from_meta.rs Outdated Show resolved Hide resolved
tests/from_meta.rs Show resolved Hide resolved
This was previously used within darling_core for `with` fields, but is
more broadly applicable.
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 TedDriggs force-pushed the from_methods branch 2 times, most recently from c22b366 to 3b8d28d Compare January 22, 2025 22:30
@TedDriggs TedDriggs merged commit a6e5f52 into master Jan 22, 2025
24 checks passed
@TedDriggs TedDriggs deleted the from_methods branch January 22, 2025 22:48
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.

Accept from_* methods as #[darling(...)] fields
1 participant