1 unstable release
Uses old Rust 2015
0.0.1 | Sep 18, 2018 |
---|
#132 in #initialization
2KB
StructEnv
initialize structs from envrionment variables
#[macro_use]
extern crate structenv_derive;
#[derive(StructEnv, Debug)]
struct Env {
foo: bool,
#[structenv(default_value = r#""bar".to_string()"#)]
bar: String,
host_address: IpAddr,
}
fn main() {
// `from_env` is generated
let env = Env::from_env();
println!("{:?}", env);
}
$ export FOO=false
$ export HOST_ADDRESS=127.0.0.2
$ cargo run -p structenv_example --bin simple
Env { foo: false, bar: "bar", host_address: V4(127.0.0.2) }