diff --git a/src/settings/mod.rs b/src/settings/mod.rs index 95a405b..13f23df 100644 --- a/src/settings/mod.rs +++ b/src/settings/mod.rs @@ -178,6 +178,28 @@ impl PartialEq for Settings { } } +impl From for Settings +where + S: ToString, +{ + /// Import settings from file path described by the argument `source` + /// + /// # Arguments + /// + /// * `source` - path to the file from which settings should be imported + /// + /// # Example + /// + /// ```no_run + /// let s = lang_evolve_core::settings::Settings::from("settings.yml"); + /// ``` + fn from(source: S) -> Self { + let source = source.to_string(); + let path = std::path::Path::new(&source); + Settings::import(&path).unwrap() + } +} + impl Eq for Settings {} #[test]