Skip to main content

ExpandVars

Derive Macro ExpandVars 

Source
#[derive(ExpandVars)]
{
    // Attributes available to this derive:
    #[expand_vars]
}
Expand description

Derive macro that implements [modkit::var_expand::ExpandVars].

Mark individual String or Option<String> fields with #[expand_vars] to have ${VAR} placeholders expanded from environment variables when expand_vars() is called.

#[derive(Deserialize, Default, ExpandVars)]
pub struct MyConfig {
    #[expand_vars]
    pub api_key: String,
    #[expand_vars]
    pub endpoint: Option<String>,
    pub retries: u32, // not expanded
}