From 22fbe5aba755d0730a61246fbc4bce49cae4c65b Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Sat, 11 Jul 2020 17:52:14 +0200 Subject: [PATCH] Add Default trait to Settings --- src/settings/mod.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/settings/mod.rs b/src/settings/mod.rs index edbf1fe..8767d27 100644 --- a/src/settings/mod.rs +++ b/src/settings/mod.rs @@ -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;