Common/shared defaults across different trait macro crates. #278
Replies: 1 comment
-
|
Hi, thank you for creating this discussion! There is indeed a problem of sharing the defaults between different data literals parsing crates (be it JSON, CLI syntax, or Rust builder syntax). I think, ideally, all of these crates will eventually align on a shared syntax thanks to the effort of rust-lang/rust#132162. That RFC seems to be on a healthy path to becoming stable. Once default field values syntax arrives in syn (dtolnay/syn#1774), However, the caveat here is that default field value syntax will support only I, personally, work around the problem of sharing the defaults by using an |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So, I often find myself in a position where I have some struct representing a layered config system or somesuch, where I need to have multiple crates, like
serde,bon, andclap, all know about a particular default. I could newtype everything, but this gets to be a bit deranged -- so I end up needing to override defaults for all crates that need to know it. Is there anything stopping the ecosystem from standardizing on some universal macro for marking field defaults in structs, such that each crate can pull that information? Or, even better, does something like that already exist? For example, if I want a specificstructfield to be atDuration::from_millis(20).Beta Was this translation helpful? Give feedback.
All reactions