subst-0.2.1 has been yanked.
subst
Shell-like variable substitution for strings and byte strings.
Features
- Perform substitution in
&stror in&[u8]. - Provide a custom map of variables or use environment variables.
- Short format:
"Hello $name!" - Long format:
"Hello ${name}!" - Default values:
"Hello ${name:person}!" - Recursive substitution in default values:
"${XDG_CONFIG_HOME:$HOME/.config}/my-app/config.toml" - Perform substitution on all string values in YAML data (optional, requires the
yamlfeature).
Variable names can consist of alphanumeric characters and underscores. They are allowed to start with numbers.
Examples
The substitute() function can be used to perform substitution on a &str.
The variables can either be a HashMap or a BTreeMap.
let mut variables = new;
variables.insert;
assert_eq!;
The variables can also be taken directly from the environment with the Env map.
assert_eq!;
Substitution can also be done on byte strings using the substitute_bytes() function.
let mut variables = new;
variables.insert;
assert_eq!;