expand-env-vars

Crates.ioexpand-env-vars
lib.rsexpand-env-vars
version0.1.0
created_at2025-04-09 14:52:23.689228+00
updated_at2025-04-09 14:52:23.689228+00
descriptionCross-platform environment variable expander for Rust (supports $VAR, ${VAR}, and %VAR%)
homepagehttps://github.com/uzaaft/expand-env-vars
repositoryhttps://github.com/uzaaft/expand-env-vars
max_upload_size
id1626917
size8,771
Uzair Aftab (Uzaaft)

documentation

https://docs.rs/expand-env-vars

README

env-expand

A simple cross-platform Rust utility to expand environment variable placeholders in strings.

Supports:

  • Unix-style: $VAR, ${VAR}
  • Windows-style: %VAR%

Missing environment variables are replaced with empty strings by default. In the future they will error out

Usage

Add to your project:

mod env_expand;

use env_expand::expand_env_vars;

fn main() {
    std::env::set_var("USERNAME", "alice");
    let input = "Hello $USERNAME!";
    
    match expand_env_vars(input) {
Commit count: 11

cargo fmt