Skip to content

KeenS/structenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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) }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages