#environment #variable #parameter #expansion #substitutaion


Unix shell-like parameter expansion/variable substitution

1 unstable release

0.1.0 Oct 2, 2022

#625 in Text processing

Custom license


Xpanda Lib

API Reference


First create a new Xpanda struct using the builder:

use xpanda::Xpanda;

let xpanda = Xpanda::builder()
    // ...

or use the default implementation:

let xpanda = Xpanda::default();

The default implementation sources values from environment variables and ignores unset variables (leaving an empty string).

The Xpanda struct implements a single method, expand, which will return a copy of the given string expanded according to the pattern rules. For example:

assert_eq!(xpanda.expand("${1:-default}"), Ok(String::from("default")));

The API Reference provides more details.


Add xpanda manually as a dependency in your Cargo.toml file or use the cargo add command:

cargo add xpanda


The Minimum Supported Rust Version is currently 1.63.


This crate provides the ability to expand/substitute variables in strings similar to envsubst and Bash parameter expansion.

There is a single public struct (not counting errors and builders), Xpanda, which in turn contains a single method: expand. The expand method takes a string by reference and returns a copy of it with all variables expanded/substituted according to some patterns.

No runtime deps