env-smart

Crates.ioenv-smart
lib.rsenv-smart
version1.0.1
sourcesrc
created_at2023-10-23 04:17:27.970903
updated_at2024-01-11 02:52:00.168446
descriptionProc macro to insert env vars into code
homepage
repositoryhttps://github.com/DoumanAsh/env-smart
max_upload_size
id1010941
size11,767
Douman (DoumanAsh)

documentation

README

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");
Commit count: 4

cargo fmt