greyblake/envconfig-rs

Add support for default attribute

greyblake opened this issue · 5 comments

Example:

#[derive(Envconfig)]
pub struct Config {
    #[from="DB_HOST"]
    pub db_host: String,

    #[from="DB_PORT", default="5432"]
    pub db_port: u16
}

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>
}

@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

@JoshMcguigan Support of Option<T> just got implemented and available starting from v0.4.0 =)

Cool, thanks 👍

Closed with #19