-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
I have some settings I wish to be able to configure over a CLI, however, the setting enum often has structs which have most of the configuration information.
pub struct NetworkSettings {
dhcp: bool,
}
pub struct UartSettings {
baud: u32
}
pub enum Setting {
/// Global network settings
Network(NetworkSettings),
/// Settings for a given uart, the first param is the uart number
Uart(usize, UartSettings),
}As things currently stand, the derive can't handle this, and would require me to duplicate the fields in the enum.
I'm wondering:
- Is there a reason why structs were not supported (is there some technical reason)?
- Would some kind of
#[flatten]attribute to handle the above conversion automatically make sense?
pub enum Setting {
/// Global network settings
Network(#[flatten] NetworkSettings),
/// Settings for a given uart, the first param is the uart number
Uart(usize, #[flatten] UartSettings),
}I'm happy to contribute, I just need a bit of direction as proc_macros are my weakest area of Rust.
Metadata
Metadata
Assignees
Labels
No labels