fix (code design): use match instead of if+unwrap
This commit is contained in:
parent
f503965a73
commit
829e90753a
14
src/main.rs
14
src/main.rs
|
@ -8,13 +8,13 @@ pub mod helper;
|
|||
use helper::settings::Settings;
|
||||
|
||||
fn main() {
|
||||
let settings_result = Settings::new();
|
||||
let settings = match Settings::new(){
|
||||
Ok(settings) => settings,
|
||||
Err(e) => {
|
||||
println!("Failed to read config: {}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
if settings_result.is_err() {
|
||||
println!("Failed to read config: {:#?}", settings_result.err());
|
||||
std::process::exit(1)
|
||||
}
|
||||
|
||||
let settings = settings_result.unwrap();
|
||||
println!("Hello, world! Default Language: {}", settings.application.default_language);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue