This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::env; | |
use std::process; | |
fn main() { | |
// HOST=myserver | |
// PORT=8080 | |
let host_key = "HOST"; | |
let port_key = "PORT"; | |
let default_port = 8080; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "rust-envy-sample" | |
version = "0.1.0" | |
authors = ["Yutaka Yawata"] | |
edition = "2018" | |
[dependencies] | |
envy = "0.3.3" | |
serde = "1.0.87" | |
serde_derive = "1.0.87" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use serde_derive::Deserialize; | |
use envy; | |
use std::process; | |
#[derive(Deserialize, Debug)] | |
struct Config { | |
host: String, | |
port: Option<u16>, | |
numbers: Vec<u64>, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use serde_derive::Deserialize; | |
use envy; | |
use std::error::Error; | |
#[derive(Deserialize, Debug)] | |
struct Config { | |
host: String, | |
#[serde(default="default_port")] | |
port: u16, | |
numbers: Vec<u64>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "rust-envconfig-sample" | |
version = "0.1.0" | |
authors = ["Yutaka Yawata"] | |
edition = "2018" | |
[dependencies] | |
envconfig = "0.5.0" | |
envconfig_derive = "0.5.0" |