Forward other derives to the partial type?
LukasKalbertodt opened this issue · 6 comments
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?
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
+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.
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.
Debug works! thank you!
Neat! Will release in the coming days. Just looking for more stuff to lump into that release.
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!