Update ron version to 0.9
This commit is contained in:
parent
995f77d1ef
commit
b812525f4b
5 changed files with 24 additions and 37 deletions
|
|
@ -1,8 +1,11 @@
|
|||
use std::{fmt, fs::File};
|
||||
use std::{
|
||||
fmt,
|
||||
fs::{self, File},
|
||||
};
|
||||
|
||||
use ron::{
|
||||
de::from_reader,
|
||||
ser::{PrettyConfig, to_writer_pretty},
|
||||
ser::{PrettyConfig, to_string_pretty},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
@ -49,25 +52,14 @@ pub fn load() -> Config {
|
|||
)
|
||||
}),
|
||||
Err(_) => {
|
||||
let mut file = File::create(consts::FILE_CONF).unwrap_or_else(|error| {
|
||||
panic!(
|
||||
"Failed to create default configuration file {}: {}",
|
||||
consts::FILE_CONF,
|
||||
error
|
||||
)
|
||||
});
|
||||
|
||||
let default_config = Config::default();
|
||||
|
||||
to_writer_pretty(&mut file, &default_config, PrettyConfig::new()).unwrap_or_else(
|
||||
|error| {
|
||||
panic!(
|
||||
"Failed to write default configuration file {}: {}",
|
||||
consts::FILE_CONF,
|
||||
error
|
||||
)
|
||||
},
|
||||
);
|
||||
let ron_string = to_string_pretty(&default_config, PrettyConfig::new())
|
||||
.unwrap_or_else(|error| panic!("Failed to serialize ron configuration: {}", error));
|
||||
|
||||
fs::write(consts::FILE_CONF, ron_string).unwrap_or_else(|error| {
|
||||
panic!("Failed to write default configuration file: {}", error)
|
||||
});
|
||||
|
||||
default_config
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue