summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorRyan Leckey <leckey.ryan@gmail.com>2017-01-28 22:07:13 -0800
committerRyan Leckey <leckey.ryan@gmail.com>2017-01-28 22:07:13 -0800
commitc1bcf6ec5537bfd0fb3f1ee8d93a32aa15031cff (patch)
tree05fd0b9a2daae99543a9d5ae3a6e15eebc622055 /src/config.rs
parent7d870758cbd9ad4181471ad40184d1bac1204e1e (diff)
Propagate Cow into Source
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/config.rs b/src/config.rs
index a1a36cb..b88b812 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -81,23 +81,23 @@ impl<'a> ConfigStore<'a> {
}
}
- fn get(&self, key: &str) -> Option<Value> {
+ fn get(&self, key: &str) -> Option<Cow<'a, Value>> {
if let ConfigStore::Mutable { ref overrides, ref sources, ref defaults } = *self {
// Check explicit override
if let Some(value) = overrides.get(key) {
- return Some(value.clone());
+ return Some(Cow::Borrowed(value));
}
// Check sources
for source in &mut sources.iter().rev() {
if let Some(value) = source.get(key) {
- return Some(value);
+ return Some(value)
}
}
// Check explicit defaults
if let Some(value) = defaults.get(key) {
- return Some(value.clone());
+ return Some(Cow::Borrowed(value));
}
}
@@ -154,7 +154,7 @@ impl<'a> Config<'a> {
}
pub fn get(&self, key: &str) -> Option<Cow<'a, Value>> {
- self.store.get(key).map(Cow::Owned)
+ self.store.get(key)
}
pub fn get_str(&'a self, key: &str) -> Option<Cow<'a, str>> {