Skip to content

Instantly share code, notes, and snippets.

@yuyawata
yuyawata / Cargo.toml
Last active October 24, 2020 20:58
Rust envconfig example
[package]
name = "rust-envconfig-sample"
version = "0.1.0"
authors = ["Yutaka Yawata"]
edition = "2018"
[dependencies]
envconfig = "0.5.0"
envconfig_derive = "0.5.0"
@yuyawata
yuyawata / main.rs
Last active February 28, 2019 06:26
Rust envy example3
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>,
@yuyawata
yuyawata / main.rs
Created February 28, 2019 05:51
Rust envy example2
use serde_derive::Deserialize;
use envy;
use std::process;
#[derive(Deserialize, Debug)]
struct Config {
host: String,
port: Option<u16>,
numbers: Vec<u64>,
}
@yuyawata
yuyawata / Cargo.toml
Last active February 28, 2019 05:44
Rust envy example1
[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"
@yuyawata
yuyawata / main.rs
Created February 28, 2019 04:37
Rust std::env example
use std::env;
use std::process;
fn main() {
// HOST=myserver
// PORT=8080
let host_key = "HOST";
let port_key = "PORT";
let default_port = 8080;