Function subst::substitute
source · pub fn substitute<'a, M>(
source: &str,
variables: &'a M
) -> Result<String, Error>where
M: VariableMap<'a> + ?Sized,
M::Value: AsRef<str>,
Expand description
Substitute variables in a string.
Variables have the form $NAME
, ${NAME}
or ${NAME:default}
.
A variable name can only consist of ASCII letters, digits and underscores.
They are allowed to start with numbers.
You can escape dollar signs, backslashes, colons and braces with a backslash.
You can pass either a HashMap
, BTreeMap
or Env
as the variables
parameter.
The maps must have &str
or String
keys, and the values must be AsRef<str>
.