+fn load_config() -> Config {
+ // unwrap_or_else(|_| panic!("Failed to open configuration file {}", consts::FILE_CONF));
+ match File::open(consts::FILE_CONF) {
+ Ok(file) => from_reader(file).unwrap_or_else(|_| panic!("Failed to open configuration file {}", consts::FILE_CONF)),
+ Err(_) => {
+ let mut file = File::create(consts::FILE_CONF) .unwrap();
+ file.write_all(to_string_pretty(&DEFAULT_CONFIG, PrettyConfig::new()).unwrap().as_bytes()).unwrap(); // We do not use 'to_writer' because it can't pretty format the output.
+ DEFAULT_CONFIG
+ }
+ }
+}
+