Added From trait to Settings
This commit is contained in:
parent
8642067eb3
commit
e00f489f55
@ -178,6 +178,28 @@ impl PartialEq for Settings {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> From<S> 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]
|
||||
|
Loading…
Reference in New Issue
Block a user