summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorRyan Leckey <leckey.ryan@gmail.com>2017-02-12 10:02:07 -0800
committerRyan Leckey <leckey.ryan@gmail.com>2017-02-12 10:02:07 -0800
commitccae9b09fa9d4650de3cf91013162a7277e46060 (patch)
treef2ff7c58a32f5418b48dd8327e6c45b74d20356c /src/config.rs
parentbcd0737e15726f3ad324c3cf26c5d04fe5f75766 (diff)
Remove global API
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/config.rs b/src/config.rs
index cdb241b..403f566 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -8,7 +8,7 @@ use std::str::FromStr;
use std::collections::HashMap;
#[derive(Default, Debug)]
-pub struct FrozenError { }
+pub struct FrozenError {}
impl fmt::Display for FrozenError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -54,13 +54,17 @@ fn merge_in_all(r: &mut HashMap<String, Value>, map: &HashMap<String, Value>) {
}
// Child ( Child ( Identifier( "x" ), "y" ), "z" )
-fn path_get_mut<'a>(root: &'a mut HashMap<String, Value>, expr: path::Expression) -> Option<&'a mut Value> {
+fn path_get_mut<'a>(root: &'a mut HashMap<String, Value>,
+ expr: path::Expression)
+ -> Option<&'a mut Value> {
match expr {
path::Expression::Identifier(text) => Some(root.entry(text.clone()).or_insert(Value::Nil)),
path::Expression::Child(expr, member) => {
match path_get_mut(root, *expr) {
- Some(&mut Value::Table(ref mut table)) => Some(table.entry(member.clone()).or_insert(Value::Nil)),
+ Some(&mut Value::Table(ref mut table)) => {
+ Some(table.entry(member.clone()).or_insert(Value::Nil))
+ }
Some(v @ _) => {
*v = Value::Table(HashMap::new());
@@ -199,7 +203,7 @@ fn path_set_str(root: &mut HashMap<String, Value>, key: &str, value: &Value) {
match path::Expression::from_str(key) {
Ok(expr) => {
path_set(root, expr, value);
- },
+ }
Err(_) => {
// TODO: Log warning here
@@ -591,7 +595,8 @@ mod test {
let m = c.get_table("redis").unwrap();
assert_eq!(m.get("port").cloned().unwrap().into_int().unwrap(), 6379);
- assert_eq!(m.get("address").cloned().unwrap().into_str().unwrap(), "::1");
+ assert_eq!(m.get("address").cloned().unwrap().into_str().unwrap(),
+ "::1");
}
{
@@ -606,7 +611,8 @@ mod test {
let m = c.get_table("redis").unwrap();
assert_eq!(m.get("port").cloned().unwrap().into_int().unwrap(), 6379);
- assert_eq!(m.get("address").cloned().unwrap().into_str().unwrap(), "::0");
+ assert_eq!(m.get("address").cloned().unwrap().into_str().unwrap(),
+ "::0");
assert_eq!(m.get("db").cloned().unwrap().into_str().unwrap(), "1");
}
}