Macro env_var_with_defaults

Source
macro_rules! env_var_with_defaults {
    ($key: expr, Option::<$type: ty>, $default: expr ) => { ... };
    ($key: expr, Option::<$type: ty>) => { ... };
    ($key: expr, $default: expr) => { ... };
    ($key: expr, $type: ty, $default: expr ) => { ... };
}
Expand description

Read environment variable using a key and default value.

  • When only (key, default_value) is passed, returns the value or the default value.

  • When the key, value return type as an Option and default_value is passed, the environment variable is read for the key and the value is parsed into the type passed as argument. If the value is not found, then the default value is assigned.

  • When the key, value return type and default_value is passed, the environment variable is read for the key and the value is parsed into the type passed as argument. If the value is not found, then the default value is assigned.