pub fn get_or_env_var(value: Option<String>, key: &str) -> Result<String>
Expand description
Returns the provided value
if Some
, otherwise falls back to reading
the environment variable for the given key
.
Only attempts to read the environment variable when value
is None
,
avoiding unnecessary environment variable lookups and errors.
ยงErrors
Returns an error if value
is None
and the environment variable is not set.