Crates.io | structenv |
lib.rs | structenv |
version | 0.0.1 |
source | src |
created_at | 2018-09-18 07:10:03.883863 |
updated_at | 2018-09-18 07:10:03.883863 |
description | initialize structs from environment variable |
homepage | |
repository | https://github.com/KeenS/structenv |
max_upload_size | |
id | 85321 |
size | 1,537 |
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) }