add a helper trait that extends Table for more convenient value retrieval
This commit is contained in:
11
src/helpers/config.rs
Normal file
11
src/helpers/config.rs
Normal 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())
|
||||
}
|
||||
}
|
@@ -1 +1,2 @@
|
||||
pub mod command;
|
||||
pub mod config;
|
||||
|
Reference in New Issue
Block a user