diff options
author | Radosław Kot <rdkt13@gmail.com> | 2021-10-17 09:36:12 +0200 |
---|---|---|
committer | Radosław Kot <rdkt13@gmail.com> | 2021-10-23 16:58:41 +0200 |
commit | 5ba9013b425b2d54b56a0f67149ceb2c50781638 (patch) | |
tree | 1754a84bef73cde196ba32115d2cb1c68ba02153 /examples | |
parent | 583a47764a93465ce8d846a6a7273a9bd38fd554 (diff) |
Apply clippy lints and format
Diffstat (limited to 'examples')
-rw-r--r-- | examples/async_source/main.rs | 10 | ||||
-rw-r--r-- | examples/custom_format/main.rs | 11 |
2 files changed, 9 insertions, 12 deletions
diff --git a/examples/async_source/main.rs b/examples/async_source/main.rs index 02f8cd7..f5459b9 100644 --- a/examples/async_source/main.rs +++ b/examples/async_source/main.rs @@ -1,6 +1,8 @@ -use std::{collections::HashMap, error::Error, fmt::Debug}; +use std::{error::Error, fmt::Debug}; -use config::{AsyncSource, ConfigBuilder, ConfigError, FileFormat, Format, builder::AsyncState, Map}; +use config::{ + builder::AsyncState, AsyncSource, ConfigBuilder, ConfigError, FileFormat, Format, Map, +}; use async_trait::async_trait; use futures::{select, FutureExt}; @@ -49,13 +51,13 @@ async fn run_client() -> Result<(), Box<dyn Error>> { // Actual implementation of AsyncSource can be found below #[derive(Debug)] -struct HttpSource<F : Format> { +struct HttpSource<F: Format> { uri: String, format: F, } #[async_trait] -impl<F : Format + Send + Sync + Debug> AsyncSource for HttpSource<F> { +impl<F: Format + Send + Sync + Debug> AsyncSource for HttpSource<F> { async fn collect(&self) -> Result<Map<String, config::Value>, ConfigError> { reqwest::get(&self.uri) .await diff --git a/examples/custom_format/main.rs b/examples/custom_format/main.rs index c149436..c21bac2 100644 --- a/examples/custom_format/main.rs +++ b/examples/custom_format/main.rs @@ -1,6 +1,4 @@ -use std::collections::HashMap; - -use config::{Config, File, FileExtensions, Format, Value, ValueKind}; +use config::{Config, File, FileExtensions, Format, Map, Value, ValueKind}; fn main() { let config = Config::builder() @@ -22,15 +20,12 @@ impl Format for MyFormat { &self, uri: Option<&String>, text: &str, - ) -> Result< - std::collections::HashMap<String, config::Value>, - Box<dyn std::error::Error + Send + Sync>, - > { + ) -> Result<Map<String, config::Value>, Box<dyn std::error::Error + Send + Sync>> { // Let's assume our format is somewhat crippled, but this is fine // In real life anything can be used here - nom, serde or other. // // For some more real-life examples refer to format implementation within the library code - let mut result = HashMap::new(); + let mut result = Map::new(); if text == "good" { result.insert( |