Add support for default attribute
greyblake opened this issue · 5 comments
greyblake commented
Example:
#[derive(Envconfig)]
pub struct Config {
#[from="DB_HOST"]
pub db_host: String,
#[from="DB_PORT", default="5432"]
pub db_port: u16
}
JoshMcguigan commented
It would also be helpful to have optional attributes, so the default behavior could be determined at run time.
#[derive(Envconfig)]
pub struct Config {
#[from="DB_HOST"]
pub db_host: String,
#[from="DB_PORT"]
pub db_port: Option<u16>
}
greyblake commented
@JoshMcguigan
Thanks! That's a good point. I had this use case in my mind weeks ago, but already forgot about it.
I'll create a separate ticket for it: #10
greyblake commented
@JoshMcguigan Support of Option<T>
just got implemented and available starting from v0.4.0
=)
JoshMcguigan commented
Cool, thanks 👍