Skip to content

feat: support partial_attr for struct fields #44

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aschey
Copy link
Contributor

@aschey aschey commented Apr 6, 2025

Related to #19

This adds support for the existing derive attribute partial_attr in struct fields. This is useful if you need to derive something on the generated partial struct that requires specifying attributes on struct fields. Being able to derive clap's traits on the partial structs is the main motivation for this, but it also works for any other trait (derive_more is the example I chose for the test).

This is most of the work required to support using partial structs with clap. More info in this comment: #19 (comment)

@@ -48,6 +48,7 @@ toml = { version = "0.8", optional = true }

[dev-dependencies]
pretty_assertions = "1.2.1"
derive_more = { version = "2.0.1", features = ["debug"] }
Copy link
Contributor Author

@aschey aschey Apr 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I unfortunately had to add a new dev dependency just for the test because I couldn't think of any derive macros in the standard library that use attributes on struct fields.

@aschey aschey force-pushed the feat/partial-attrs branch from 843ba9e to bf7583b Compare April 7, 2025 02:13
@aschey aschey changed the title feat: support partial_attr for struct fields feat: support partial_attr for struct fields Apr 7, 2025
@aschey aschey force-pushed the feat/partial-attrs branch from bf7583b to 46e661e Compare April 7, 2025 03:10
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.

1 participant