From d95304bbd35c318d7390d1a42afe04276f7af9b9 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Wed, 13 Dec 2023 10:03:54 +0100 Subject: [PATCH] remove lint warnings Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- twelf/examples/expand.rs | 11 ++++++++++- twelf/tests/clap.rs | 16 +++++++--------- twelf/tests/mixed.rs | 12 ++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/twelf/examples/expand.rs b/twelf/examples/expand.rs index 6c141d0..74c5375 100644 --- a/twelf/examples/expand.rs +++ b/twelf/examples/expand.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; -use twelf::reexports::serde::{Deserialize, Serialize}; use twelf::{config, Layer}; #[config] @@ -13,6 +12,16 @@ pub struct Settings { pub profiles: HashMap>, } +fn main() { + let config = Settings::with_layers(&[ + Layer::Toml("./examples/config.toml".into()), + Layer::Env(Some(String::from("TERRAPHIM_"))), + ]) + .unwrap(); + + println!("config - {:?}", config); +} + #[cfg(test)] mod tests { use super::*; diff --git a/twelf/tests/clap.rs b/twelf/tests/clap.rs index d5f1b1a..53398b8 100644 --- a/twelf/tests/clap.rs +++ b/twelf/tests/clap.rs @@ -2,8 +2,8 @@ use std::collections::HashMap; -use clap_rs as clap; use clap::{CommandFactory, Parser}; +use clap_rs as clap; use config_derive::config; use twelf::Layer; @@ -28,7 +28,7 @@ fn clap_with_array_and_hashmap() { .unwrap() .contains("My custom documentation on elements-snake in clap")); - let matches = app.get_matches_from(&[ + let matches = app.get_matches_from([ "test", "--arrays=first,second", "--elements-snake=coucou=toi,hello=you", @@ -52,7 +52,7 @@ fn clap_with_array_and_hashmap() { #[test] fn clap_derive_array() { #[config] - #[derive(Parser,Debug, Default)] + #[derive(Parser, Debug, Default)] #[clap(author, version, about, long_about = None)] struct Conf { #[clap(long, default_value_t = 55)] @@ -62,17 +62,15 @@ fn clap_derive_array() { arrays: Vec, } - let matches = Conf::command().get_matches_from(&[ + let matches = Conf::command().get_matches_from([ "test", "--arrays=asdf", "--some-val=14", - "--arrays=qwer,zxc" + "--arrays=qwer,zxc", ]); - let prio = vec![ - Layer::Clap(matches), - ]; + let prio = vec![Layer::Clap(matches)]; let config = Conf::with_layers(&prio).unwrap(); - assert_eq!(config.arrays, vec!["asdf","qwer","zxc"]); + assert_eq!(config.arrays, vec!["asdf", "qwer", "zxc"]); } diff --git a/twelf/tests/mixed.rs b/twelf/tests/mixed.rs index f63168a..dc90063 100644 --- a/twelf/tests/mixed.rs +++ b/twelf/tests/mixed.rs @@ -1,5 +1,4 @@ #![cfg(all(feature = "toml", feature = "json"))] - #![allow(dead_code)] use std::collections::HashMap; @@ -237,19 +236,16 @@ fn mixed_clap_defaults() { array_def: Vec, } - let matches = Conf::command().get_matches_from(&["test", "--array-def=asdf,qwer"]); + let matches = Conf::command().get_matches_from(["test", "--array-def=asdf,qwer"]); std::env::set_var("STRING_DEF", "coucou toi"); - let prio = vec![ - Layer::Env(None), - Layer::Clap(matches), - ]; + let prio = vec![Layer::Env(None), Layer::Clap(matches)]; let config = Conf::with_layers(&prio).unwrap(); let vec = vec!["asdf", "qwer"]; assert_eq!(config.string_def, "coucou toi"); // Env Layer - assert_eq!(config.some_num, 55); // Clap default - assert_eq!(config.array_def, vec); // Clap CLI + assert_eq!(config.some_num, 55); // Clap default + assert_eq!(config.array_def, vec); // Clap CLI }