greyblake/envconfig-rs

Support compile-time defaults

rasviitanen opened this issue · 2 comments

It would be beneficial to be able to use environment variables in defaults via the "env!"-macro.

This would allow you to do something like this:

#[derive(Clone, Debug, Envconfig)]
pub struct Config {
    #[envconfig(
        from = "CUSTOM_LOG_DIR",
        default = env!("DEFAULT_LOG_DIR")
    )]
    pub log_location: String,
}

And get a compilation error "error: environment variable DEFAULT_LOG_DIR not defined" if it isn't accessible.

Is there any update on this?

@KaloyanYosifov

Hi no, not yet. But if multiple people demand it I will considering adding it.