Created
March 23, 2020 14:48
-
-
Save BetterProgramming/0f9004ef08fb3126774669e3f30843ae to your computer and use it in GitHub Desktop.
This file contains 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 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