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

Forward other derives to the partial type? #17

Closed
LukasKalbertodt opened this issue Oct 21, 2022 · 6 comments
Closed

Forward other derives to the partial type? #17

LukasKalbertodt opened this issue Oct 21, 2022 · 6 comments

Comments

@LukasKalbertodt
Copy link
Owner

We cannot see other derives, only in special circumstances. Thus we probably want #[config(derive_for_partial = Debug)] or sth.
Maybe a more general attribute forward? Or just derive Debug and nothing else?

@hmuendel
Copy link

I really like to print the final merged config and how it was composed from it's partial configs, but having neither Clone nor Debug made it hard for me and I ended up implementing a printable wrapper type for each of my nested configs and std::mem::replacing the original nested configs into my root partial config wrapper.
We could also have a feature flag like ConfigExt which brings an extra set of derive trait implementations, e.g. Debug, Clone, Serialize

@jdx
Copy link

jdx commented Dec 4, 2023

+1 to this one, not having Clone has been particularly painful for me trying to integrate into rtx.

Aside from this I've been really happy with confique though. I used figment before but really love having the partial config object. It makes integrating it into an existing highly complex configuration struct much, much easier.

@LukasKalbertodt
Copy link
Owner Author

I just pushed a commit that adds #[config(partial_attr(...))]. This allows you to write this:

#[derive(Config)]
#[config(partial_attr(derive(Clone)))]
struct Conf { ... }

And the partial type will get #[derive(Clone)] as attribute.

It would be great if any of you could test that to see if it solves your problem.

@jdx
Copy link

jdx commented Dec 8, 2023

Debug works! thank you!

jdx/mise#1131

@LukasKalbertodt
Copy link
Owner Author

Neat! Will release in the coming days. Just looking for more stuff to lump into that release.

@LukasKalbertodt
Copy link
Owner Author

Released as v0.2.5


Aside from this I've been really happy with confique though. I used figment before but really love having the partial config object. It makes integrating it into an existing highly complex configuration struct much, much easier.

Thanks for this experience report by the way! It's always great to hear others getting value out of my work, but especially so in this case: when researching configuration libraries and when I concluded that I didn't like any of the existing ones, I somehow missed figment completely. So when I found figment after having created confique already, I felt kinda dumb because figment had most of what I wanted. So yeah, very good to hear that confique makes sense as an alternative to figment!

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

3 participants