19 lines
494 B
Rust
Raw Normal View History

2018-05-12 00:41:04 -05:00
use toml;
use toml::value::Table;
pub trait Config {
fn get_string (&self, key: &str) -> Option<&str>;
2018-05-12 00:41:04 -05:00
fn get_vec (&self, key: &str) -> Option<Vec<toml::Value>>;
}
impl Config for Table {
fn get_string (&self, key: &str) -> Option<&str> {
self.get(key).and_then(|value| value.as_str())
}
2018-05-12 00:41:04 -05:00
fn get_vec (&self, key: &str) -> Option<Vec<toml::Value>> {
self.get(key).and_then(|value| value.as_array())
.map(|value| value.to_vec())
}
}