use default trait
This commit is contained in:
parent
d57231cfc4
commit
6b932d45ba
1 changed files with 4 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
|||
use serde::Deserialize;
|
||||
use std::fs;
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
#[derive(Deserialize, Clone, Default)]
|
||||
pub struct Config {
|
||||
pub scheme: Option<String>,
|
||||
pub port: Option<u16>,
|
||||
|
@ -9,7 +10,7 @@ pub struct Config {
|
|||
}
|
||||
|
||||
pub fn get_config(file_path: &str) -> Config {
|
||||
match std::fs::read_to_string(file_path) {
|
||||
match fs::read_to_string(file_path) {
|
||||
Ok(file) => match toml::from_str(&file) {
|
||||
Ok(stored_config) => stored_config,
|
||||
Err(file_error) => {
|
||||
|
@ -19,12 +20,7 @@ pub fn get_config(file_path: &str) -> Config {
|
|||
Err(_) =>
|
||||
// No config file
|
||||
{
|
||||
Config {
|
||||
scheme: None,
|
||||
port: None,
|
||||
mail: None,
|
||||
lang: None,
|
||||
}
|
||||
Config::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue