diff --git a/src/config.rs b/src/config.rs index 3ec3a16..be1a23f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,7 @@ use serde::Deserialize; +use std::fs; -#[derive(Deserialize, Clone)] +#[derive(Deserialize, Clone, Default)] pub struct Config { pub scheme: Option, pub port: Option, @@ -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() } } }