envcast_derive
Overview
envcast_derive provides the FromEnv procedural macro for Rust structs.
It generates a get() method that resolves struct fields using the following order:
- Environment variables (field name as-is, then uppercase)
.envfiles (default.env, thenDOTENV_CONFIG_FILE), lowercase and uppercase keys#[default = "..."]attributeDefault::default()
Each field type must implement:
std::str::FromStrDefault
Usage
use FromEnv;
Then:
let cfg = get;
Config::get() returns a struct with all fields resolved according to the priority rules above.
License
MIT