Add Default trait to Settings

This commit is contained in:
Lucien Cartier-Tilet 2020-07-11 17:52:14 +02:00
parent 9cc1a52e5a
commit 22fbe5aba7
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
1 changed files with 22 additions and 0 deletions

View File

@ -370,6 +370,28 @@ impl Settings {
}
}
impl Default for Settings {
/// Creates a new empty instance of [`Settings`]
///
/// # Example
///
/// ```
/// let s = lang_evolve_core::settings::Settings::default();
/// let content_yaml = r#"---
/// version: "1"
/// categories: {}
/// rules: []"#;
/// let content_json = r#"{"version":"1","categories":{},"rules":[]}"#;
/// assert_eq!(content_yaml, serde_yaml::to_string(&s).unwrap());
/// assert_eq!(content_json, serde_json::to_string(&s).unwrap());
/// ```
///
/// [`Settings`]: ./settings/struct.Settings.html
fn default() -> Self {
Self::new()
}
}
use std::str::FromStr;
impl FromStr for Settings {
type Err = serde_yaml::Error;