Add Default trait to Settings

此提交包含在:
2020-07-11 17:52:14 +02:00
父節點 9cc1a52e5a
當前提交 22fbe5aba7

查看文件

@@ -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; use std::str::FromStr;
impl FromStr for Settings { impl FromStr for Settings {
type Err = serde_yaml::Error; type Err = serde_yaml::Error;