summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDavid Orchard <if_coding@fastmail.com>2021-07-28 22:52:15 -0700
committerDavid Orchard <if_coding@fastmail.com>2021-08-15 10:31:18 -0700
commitfc8cf0ed674cbb495df1baff34d4b832ca5fad3c (patch)
treea83c82ff11399ebd2da8d7ae58da31b7f295998c /examples
parent62c84297e5340d717d89c5c0b36ed86dd5ad9d2f (diff)
Use LinkedHashMap in place of HashMap
Diffstat (limited to 'examples')
-rw-r--r--examples/async_source/main.rs5
-rw-r--r--examples/glob/src/main.rs14
-rw-r--r--examples/simple/src/main.rs6
-rw-r--r--examples/watch/src/main.rs4
4 files changed, 15 insertions, 14 deletions
diff --git a/examples/async_source/main.rs b/examples/async_source/main.rs
index 10befe0..6c836a3 100644
--- a/examples/async_source/main.rs
+++ b/examples/async_source/main.rs
@@ -1,4 +1,5 @@
-use std::{collections::HashMap, error::Error};
+use linked_hash_map::LinkedHashMap;
+use std::error::Error;
use config::{builder::AsyncState, AsyncSource, ConfigBuilder, ConfigError, FileFormat};
@@ -56,7 +57,7 @@ struct HttpSource {
#[async_trait]
impl AsyncSource for HttpSource {
- async fn collect(&self) -> Result<HashMap<String, config::Value>, ConfigError> {
+ async fn collect(&self) -> Result<LinkedHashMap<String, config::Value>, ConfigError> {
reqwest::get(&self.uri)
.await
.map_err(|e| ConfigError::Foreign(Box::new(e)))? // error conversion is possible from custom AsyncSource impls
diff --git a/examples/glob/src/main.rs b/examples/glob/src/main.rs
index b3183ef..c85f86e 100644
--- a/examples/glob/src/main.rs
+++ b/examples/glob/src/main.rs
@@ -1,5 +1,5 @@
use std::path::Path;
-use std::collections::HashMap;
+use std::collections::LinkedHashMap;
use config::*;
use glob::glob;
@@ -14,9 +14,9 @@ fn main() {
.merge(File::from(Path::new("conf/05-some.yml"))).unwrap()
.merge(File::from(Path::new("conf/99-extra.json"))).unwrap();
- // Print out our settings (as a HashMap)
+ // Print out our settings (as a LinkedHashMap)
println!("\n{:?} \n\n-----------",
- settings.try_into::<HashMap<String, String>>().unwrap());
+ settings.try_into::<LinkedHashMap<String, String>>().unwrap());
// Option 2
// --------
@@ -28,9 +28,9 @@ fn main() {
File::from(Path::new("conf/99-extra.json"))])
.unwrap();
- // Print out our settings (as a HashMap)
+ // Print out our settings (as a LinkedHashMap)
println!("\n{:?} \n\n-----------",
- settings.try_into::<HashMap<String, String>>().unwrap());
+ settings.try_into::<LinkedHashMap<String, String>>().unwrap());
// Option 3
// --------
@@ -43,7 +43,7 @@ fn main() {
.collect::<Vec<_>>())
.unwrap();
- // Print out our settings (as a HashMap)
+ // Print out our settings (as a LinkedHashMap)
println!("\n{:?} \n\n-----------",
- settings.try_into::<HashMap<String, String>>().unwrap());
+ settings.try_into::<LinkedHashMap<String, String>>().unwrap());
}
diff --git a/examples/simple/src/main.rs b/examples/simple/src/main.rs
index 1c7ddb7..698401a 100644
--- a/examples/simple/src/main.rs
+++ b/examples/simple/src/main.rs
@@ -1,4 +1,4 @@
-use std::collections::HashMap;
+use std::collections::LinkedHashMap;
fn main() {
let mut settings = config::Config::default();
@@ -9,7 +9,7 @@ fn main() {
// Eg.. `APP_DEBUG=1 ./target/app` would set the `debug` key
.merge(config::Environment::with_prefix("APP")).unwrap();
- // Print out our settings (as a HashMap)
+ // Print out our settings (as a LinkedHashMap)
println!("{:?}",
- settings.try_into::<HashMap<String, String>>().unwrap());
+ settings.try_into::<LinkedHashMap<String, String>>().unwrap());
}
diff --git a/examples/watch/src/main.rs b/examples/watch/src/main.rs
index a197390..9e676ad 100644
--- a/examples/watch/src/main.rs
+++ b/examples/watch/src/main.rs
@@ -1,5 +1,5 @@
use config::*;
-use std::collections::HashMap;
+use std::collections::LinkedHashMap;
use std::sync::RwLock;
use notify::{RecommendedWatcher, DebouncedEvent, Watcher, RecursiveMode};
use std::sync::mpsc::channel;
@@ -20,7 +20,7 @@ fn show() {
.read()
.unwrap()
.clone()
- .try_into::<HashMap<String, String>>()
+ .try_into::<LinkedHashMap<String, String>>()
.unwrap());
}