Skip to main content

expand_env_placeholders

Function expand_env_placeholders 

Source
pub fn expand_env_placeholders(input: &str) -> String
Expand description

Expand ${VAR} and ${VAR:-default} placeholders from the process environment, leaving unresolvable placeholders untouched.

This lenient form exists for values that are resolved in a later stage — notably a remote entry’s env map, where ${TAVILY_API_KEY} is expected to survive process-env expansion so the URL resolver can substitute it. Use expand_env_placeholders_strict anywhere the expanded value is consumed immediately.

§Examples

// A `${VAR:-default}` with no env var set falls back to the default.
assert_eq!(
    expand_env_placeholders("${UAR_DOC_UNSET_VAR:-http://127.0.0.1:1906}"),
    "http://127.0.0.1:1906"
);