fix (code design): use match instead of if+unwrap

This commit is contained in:
Keanu D?lle 2020-01-15 12:36:57 +01:00
parent f503965a73
commit 829e90753a

View File

@ -8,13 +8,13 @@ pub mod helper;
use helper::settings::Settings; use helper::settings::Settings;
fn main() { fn main() {
let settings_result = Settings::new(); let settings = match Settings::new(){
Ok(settings) => settings,
if settings_result.is_err() { Err(e) => {
println!("Failed to read config: {:#?}", settings_result.err()); println!("Failed to read config: {}", e);
std::process::exit(1) std::process::exit(1);
} }
};
let settings = settings_result.unwrap();
println!("Hello, world! Default Language: {}", settings.application.default_language); println!("Hello, world! Default Language: {}", settings.application.default_language);
} }