env-smart 1.0.1

Proc macro to insert env vars into code
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 2 items with examples
  • Size
  • Source code size: 11.42 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 277.06 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • DoumanAsh/env-smart
    0 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • DoumanAsh

env-smart

Rust Crates.io Documentation

Improved version of env! macro from std.

Syntax:

  • Standard env! - If plain string specified then behavior is the same as standard env macro
  • Simplified formatting - Allows to format string using multiple variables enveloped into {} brackets. Note that bracket escaping is not supported

Sources

Macro fetches environment variables in following order:

  • Use .env file from root where build is run. Duplicate values are not allowed.
  • Use current environment where proc macro runs. It will not override .env variables

Usage

use env_smart::env;

static USER_AGENT: &str = env!("{CARGO_PKG_NAME}-{CARGO_PKG_VERSION}");

assert_eq!(USER_AGENT, "env-smart-1.0.0");