Skip to main content

get_or_env_var_opt

Function get_or_env_var_opt 

Source
pub fn get_or_env_var_opt(value: Option<String>, key: &str) -> Option<String>
Expand description

Returns the provided value if Some, otherwise falls back to reading the environment variable for the given key.

Unlike get_or_env_var, this function returns None instead of an error when the environment variable is not set. Use this for optional credentials where missing values are acceptable (e.g., public-only API clients).