From fc8cf0ed674cbb495df1baff34d4b832ca5fad3c Mon Sep 17 00:00:00 2001 From: David Orchard Date: Wed, 28 Jul 2021 22:52:15 -0700 Subject: Use LinkedHashMap in place of HashMap --- src/source.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/source.rs') diff --git a/src/source.rs b/src/source.rs index 831e4c4..7d257d0 100644 --- a/src/source.rs +++ b/src/source.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use linked_hash_map::LinkedHashMap; use std::fmt::Debug; use std::str::FromStr; @@ -13,8 +13,8 @@ pub trait Source: Debug { fn clone_into_box(&self) -> Box; /// Collect all configuration properties available from this source and return - /// a HashMap. - fn collect(&self) -> Result>; + /// a LinkedHashMap. + fn collect(&self) -> Result>; /// Collects all configuration properties to a provided cache. fn collect_to(&self, cache: &mut Value) -> Result<()> { @@ -55,8 +55,8 @@ pub trait AsyncSource: Debug + Sync { // Sync is supertrait due to https://docs.rs/async-trait/0.1.50/async_trait/index.html#dyn-traits /// Collects all configuration properties available from this source and return - /// a HashMap as an async operations. - async fn collect(&self) -> Result>; + /// a LinkedHashMap as an async operations. + async fn collect(&self) -> Result>; /// Collects all configuration properties to a provided cache. async fn collect_to(&self, cache: &mut Value) -> Result<()> { @@ -86,8 +86,8 @@ impl Source for Vec> { Box::new((*self).clone()) } - fn collect(&self) -> Result> { - let mut cache: Value = HashMap::::new().into(); + fn collect(&self) -> Result> { + let mut cache: Value = LinkedHashMap::::new().into(); for source in self { source.collect_to(&mut cache)?; @@ -106,8 +106,8 @@ impl Source for [Box] { Box::new(self.to_owned()) } - fn collect(&self) -> Result> { - let mut cache: Value = HashMap::::new().into(); + fn collect(&self) -> Result> { + let mut cache: Value = LinkedHashMap::::new().into(); for source in self { source.collect_to(&mut cache)?; @@ -131,8 +131,8 @@ where Box::new((*self).clone()) } - fn collect(&self) -> Result> { - let mut cache: Value = HashMap::::new().into(); + fn collect(&self) -> Result> { + let mut cache: Value = LinkedHashMap::::new().into(); for source in self { source.collect_to(&mut cache)?; -- cgit v1.2.3