Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created March 23, 2020 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/0f9004ef08fb3126774669e3f30843ae to your computer and use it in GitHub Desktop.
Save BetterProgramming/0f9004ef08fb3126774669e3f30843ae to your computer and use it in GitHub Desktop.
use ron::de;
pub fn load() -> std::io::Result<Config> {
let input_path = format!("{}/config.ron", env!("CARGO_MANIFEST_DIR"));
let f = std::fs::File::open(&input_path).expect("Failed opening file");
let config: Config = match de::from_reader(f) {
Ok(x) => x,
Err(e) => {
println!("Failed to load config: {}", e);
std::process::exit(1);
}
};
return Ok(config);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment