Skip to content

Instantly share code, notes, and snippets.

@strangeglyph
Created May 28, 2018 22:11
Show Gist options
  • Save strangeglyph/e92fb18eb0d4d85ddb548526b298ce8d to your computer and use it in GitHub Desktop.
Save strangeglyph/e92fb18eb0d4d85ddb548526b298ce8d to your computer and use it in GitHub Desktop.
#[derive(Debug, Serialize, Deserialize)]
struct Thing {
value: String,
}
pub fn do_the_thing() {
let mut cfg = cfg::Config::default();
cfg.set("value", "didn't do the thing").unwrap();
cfg.merge(cfg::File::with_name("./thing.yml")).unwrap();
// ---
// value: did the thing
let thing: Thing = cfg.try_into().unwrap();
println!("{}", thing.value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment