diff options
author | David Orchard <if_coding@fastmail.com> | 2021-08-01 00:03:10 -0700 |
---|---|---|
committer | David Orchard <if_coding@fastmail.com> | 2021-08-15 10:31:58 -0700 |
commit | cc0530a7716779f954b1756905a9f4ceb7eb6d62 (patch) | |
tree | 311b2ca44a282bbc629a08123f53a855cba38c1c /src/builder.rs | |
parent | 622efaca17256fb42dafc61c8df1f3037c1fb772 (diff) |
Move order preservation under a feature gate
Diffstat (limited to 'src/builder.rs')
-rw-r--r-- | src/builder.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/builder.rs b/src/builder.rs index 65f49ae..5100f5f 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1,8 +1,9 @@ -use linked_hash_map::LinkedHashMap; use std::iter::IntoIterator; use std::str::FromStr; + use crate::error::Result; +use crate::map::MapImpl; use crate::source::AsyncSource; use crate::{config::Config, path::Expression, source::Source, value::Value}; @@ -88,8 +89,8 @@ use crate::{config::Config, path::Expression, source::Source, value::Value}; /// ``` #[derive(Debug, Clone, Default)] pub struct ConfigBuilder<St: BuilderState> { - defaults: LinkedHashMap<Expression, Value>, - overrides: LinkedHashMap<Expression, Value>, + defaults: MapImpl<Expression, Value>, + overrides: MapImpl<Expression, Value>, state: St, } @@ -121,8 +122,8 @@ pub struct DefaultState { /// Refer to [`ConfigBuilder`] for similar API sample usage or to the examples folder of the crate, where such a source is implemented. #[derive(Debug, Clone, Default)] pub struct AsyncConfigBuilder { - defaults: LinkedHashMap<Expression, Value>, - overrides: LinkedHashMap<Expression, Value>, + defaults: MapImpl<Expression, Value>, + overrides: MapImpl<Expression, Value>, sources: Vec<SourceType>, } @@ -245,11 +246,11 @@ impl ConfigBuilder<DefaultState> { } fn build_internal( - defaults: LinkedHashMap<Expression, Value>, - overrides: LinkedHashMap<Expression, Value>, + defaults: MapImpl<Expression, Value>, + overrides: MapImpl<Expression, Value>, sources: &[Box<dyn Source + Send + Sync>], ) -> Result<Config> { - let mut cache: Value = LinkedHashMap::<String, Value>::new().into(); + let mut cache: Value = MapImpl::<String, Value>::new().into(); // Add defaults for (key, val) in defaults.into_iter() { @@ -323,11 +324,11 @@ impl ConfigBuilder<AsyncState> { } async fn build_internal( - defaults: LinkedHashMap<Expression, Value>, - overrides: LinkedHashMap<Expression, Value>, + defaults: MapImpl<Expression, Value>, + overrides: MapImpl<Expression, Value>, sources: &[SourceType], ) -> Result<Config> { - let mut cache: Value = LinkedHashMap::<String, Value>::new().into(); + let mut cache: Value = MapImpl::<String, Value>::new().into(); // Add defaults for (key, val) in defaults.into_iter() { |