From 2b438ed9b53fee5689032f3b5fcdda8d15becd5f Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Thu, 22 Jun 2017 14:14:29 -0700 Subject: Add builder API to Config --- src/env.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/env.rs') diff --git a/src/env.rs b/src/env.rs index a0b190b..abadea2 100644 --- a/src/env.rs +++ b/src/env.rs @@ -4,6 +4,7 @@ use error::*; use source::Source; use value::{Value, ValueKind}; +#[derive(Clone, Debug)] pub struct Environment { /// Optional prefix that will limit access to the environment to only keys that /// begin with the defined prefix. @@ -29,7 +30,10 @@ impl Environment { } pub fn with_prefix(s: &str) -> Self { - Environment { prefix: Some(s.into()), ..Environment::default() } + Environment { + prefix: Some(s.into()), + ..Environment::default() + } } pub fn prefix(&mut self, s: String) -> &mut Self { @@ -53,6 +57,10 @@ impl Default for Environment { } impl Source for Environment { + fn clone_into_box(&self) -> Box { + Box::new((*self).clone()) + } + fn collect(&self) -> Result> { let mut m = HashMap::new(); let uri: String = "the environment".into(); @@ -80,7 +88,8 @@ impl Source for Environment { // Replace `separator` with `.` key = key.replace(&self.separator, "."); - m.insert(key.to_lowercase(), Value::new(Some(&uri), ValueKind::String(value))); + m.insert(key.to_lowercase(), + Value::new(Some(&uri), ValueKind::String(value))); } Ok(m) -- cgit v1.2.3