add a helper trait that extends Table for more convenient value retrieval
This commit is contained in:
parent
cbf1688bdd
commit
0d4718c3f3
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user