add a helper trait that extends Table for more convenient value retrieval

This commit is contained in:
Adrian Malacoda 2018-05-12 00:11:44 -05:00
parent cbf1688bdd
commit 0d4718c3f3
2 changed files with 12 additions and 0 deletions

11
src/helpers/config.rs Normal file
View File

@ -0,0 +1,11 @@
use toml::value::Table;
pub trait Config {
fn get_string (&self, key: &str) -> Option<&str>;
}
impl Config for Table {
fn get_string (&self, key: &str) -> Option<&str> {
self.get(key).and_then(|value| value.as_str())
}
}

View File

@ -1 +1,2 @@
pub mod command; pub mod command;
pub mod config;