diff options
author | David Orchard <if_coding@fastmail.com> | 2021-07-28 22:52:15 -0700 |
---|---|---|
committer | David Orchard <if_coding@fastmail.com> | 2021-08-15 10:31:18 -0700 |
commit | fc8cf0ed674cbb495df1baff34d4b832ca5fad3c (patch) | |
tree | a83c82ff11399ebd2da8d7ae58da31b7f295998c /src/config.rs | |
parent | 62c84297e5340d717d89c5c0b36ed86dd5ad9d2f (diff) |
Use LinkedHashMap in place of HashMap
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/config.rs b/src/config.rs index b9c64b4..6302c45 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use linked_hash_map::LinkedHashMap; use std::fmt::Debug; use crate::builder::{ConfigBuilder, DefaultState}; @@ -16,8 +16,8 @@ use crate::value::{Table, Value}; /// them according to the source's priority. #[derive(Clone, Debug)] pub struct Config { - defaults: HashMap<path::Expression, Value>, - overrides: HashMap<path::Expression, Value>, + defaults: LinkedHashMap<path::Expression, Value>, + overrides: LinkedHashMap<path::Expression, Value>, sources: Vec<Box<dyn Source + Send + Sync>>, /// Root of the cached configuration. @@ -83,7 +83,7 @@ impl Config { #[deprecated(since = "0.12.0", note = "please use 'ConfigBuilder' instead")] pub fn refresh(&mut self) -> Result<&mut Config> { self.cache = { - let mut cache: Value = HashMap::<String, Value>::new().into(); + let mut cache: Value = LinkedHashMap::<String, Value>::new().into(); // Add defaults for (key, val) in self.defaults.iter() { @@ -181,7 +181,7 @@ impl Config { self.get(key).and_then(Value::into_bool) } - pub fn get_table(&self, key: &str) -> Result<HashMap<String, Value>> { + pub fn get_table(&self, key: &str) -> Result<LinkedHashMap<String, Value>> { self.get(key).and_then(Value::into_table) } @@ -212,7 +212,7 @@ impl Source for Config { Box::new((*self).clone()) } - fn collect(&self) -> Result<HashMap<String, Value>> { + fn collect(&self) -> Result<LinkedHashMap<String, Value>> { self.cache.clone().into_table() } } |