diff --git a/Cargo.toml b/Cargo.toml index 90b38b27..f9882eac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,71 +19,71 @@ include = [ [workspace.lints.rust] # rust_2018_idioms = { level = "warn", priority = -1 } -# unreachable_pub = "warn" +unreachable_pub = "warn" unsafe_op_in_unsafe_fn = "warn" unused_lifetimes = "warn" unused_macro_rules = "warn" -# unused_qualifications = "warn" +unused_qualifications = "warn" [workspace.lints.clippy] bool_assert_comparison = "allow" branches_sharing_code = "allow" -# checked_conversions = "warn" +checked_conversions = "warn" collapsible_else_if = "allow" -# create_dir = "warn" -# dbg_macro = "warn" -# debug_assert_with_mut_call = "warn" -# doc_markdown = "warn" -# empty_enum = "warn" -# enum_glob_use = "warn" -# expl_impl_clone_on_copy = "warn" -# explicit_deref_methods = "warn" -# explicit_into_iter_loop = "warn" -# fallible_impl_from = "warn" -# filter_map_next = "warn" -# flat_map_option = "warn" -# float_cmp_const = "warn" -# fn_params_excessive_bools = "warn" -# from_iter_instead_of_collect = "warn" +create_dir = "warn" +dbg_macro = "warn" +debug_assert_with_mut_call = "warn" +doc_markdown = "warn" +empty_enum = "warn" +enum_glob_use = "warn" +expl_impl_clone_on_copy = "warn" +explicit_deref_methods = "warn" +explicit_into_iter_loop = "warn" +fallible_impl_from = "warn" +filter_map_next = "warn" +flat_map_option = "warn" +float_cmp_const = "warn" +fn_params_excessive_bools = "warn" +from_iter_instead_of_collect = "warn" if_same_then_else = "allow" -# implicit_clone = "warn" -# imprecise_flops = "warn" -# inconsistent_struct_constructor = "warn" -# inefficient_to_string = "warn" -# infinite_loop = "warn" -# invalid_upcast_comparisons = "warn" -# large_digit_groups = "warn" -# large_stack_arrays = "warn" -# large_types_passed_by_value = "warn" +implicit_clone = "warn" +imprecise_flops = "warn" +inconsistent_struct_constructor = "warn" +inefficient_to_string = "warn" +infinite_loop = "warn" +invalid_upcast_comparisons = "warn" +large_digit_groups = "warn" +large_stack_arrays = "warn" +large_types_passed_by_value = "warn" let_and_return = "allow" # sometimes good to name what you are returning -# linkedlist = "warn" -# lossy_float_literal = "warn" -# macro_use_imports = "warn" -# mem_forget = "warn" -# mutex_integer = "warn" -# needless_continue = "warn" -# needless_for_each = "warn" -# negative_feature_names = "warn" -# path_buf_push_overwrite = "warn" -# ptr_as_ptr = "warn" -# rc_mutex = "warn" -# redundant_feature_names = "warn" -# ref_option_ref = "warn" -# rest_pat_in_fully_bound_structs = "warn" -# same_functions_in_if_condition = "warn" -# self_named_module_files = "warn" -# semicolon_if_nothing_returned = "warn" -# str_to_string = "warn" -# string_add = "warn" -# string_add_assign = "warn" -# string_lit_as_bytes = "warn" -# string_to_string = "warn" -# todo = "warn" -# trait_duplication_in_bounds = "warn" -# uninlined_format_args = "warn" -# verbose_file_reads = "warn" -# wildcard_imports = "warn" -# zero_sized_map_values = "warn" +linkedlist = "warn" +lossy_float_literal = "warn" +macro_use_imports = "warn" +mem_forget = "warn" +mutex_integer = "warn" +needless_continue = "warn" +needless_for_each = "warn" +negative_feature_names = "warn" +path_buf_push_overwrite = "warn" +ptr_as_ptr = "warn" +rc_mutex = "warn" +redundant_feature_names = "warn" +ref_option_ref = "warn" +rest_pat_in_fully_bound_structs = "warn" +same_functions_in_if_condition = "warn" +self_named_module_files = "warn" +semicolon_if_nothing_returned = "warn" +str_to_string = "warn" +string_add = "warn" +string_add_assign = "warn" +string_lit_as_bytes = "warn" +string_to_string = "warn" +todo = "warn" +trait_duplication_in_bounds = "warn" +uninlined_format_args = "warn" +verbose_file_reads = "warn" +wildcard_imports = "warn" +zero_sized_map_values = "warn" [package] name = "config" diff --git a/examples/custom_file_format/main.rs b/examples/custom_file_format/main.rs index cc919ca8..e22901cf 100644 --- a/examples/custom_file_format/main.rs +++ b/examples/custom_file_format/main.rs @@ -23,7 +23,7 @@ fn main() { // Deserialize the config object into your Settings struct: let settings: Settings = settings.try_deserialize().unwrap(); - println!("{:#?}", settings); + println!("{settings:#?}"); } #[derive(Debug, Clone)] @@ -34,7 +34,7 @@ impl Format for PemFile { &self, uri: Option<&String>, text: &str, - ) -> Result, Box> { + ) -> Result, Box> { // Store any valid keys into this map, they'll be merged with other sources into the final config map: let mut result = Map::new(); diff --git a/examples/custom_str_format/main.rs b/examples/custom_str_format/main.rs index 4da2e9dc..e78f2a9e 100644 --- a/examples/custom_str_format/main.rs +++ b/examples/custom_str_format/main.rs @@ -7,8 +7,8 @@ fn main() { .build(); match config { - Ok(cfg) => println!("A config: {:#?}", cfg), - Err(e) => println!("An error: {}", e), + Ok(cfg) => println!("A config: {cfg:#?}"), + Err(e) => println!("An error: {e}"), } } @@ -20,7 +20,7 @@ impl Format for MyFormat { &self, uri: Option<&String>, text: &str, - ) -> Result, Box> { + ) -> Result, Box> { // Let's assume our format is somewhat malformed, but this is fine // In real life anything can be used here - nom, serde or other. // @@ -29,11 +29,11 @@ impl Format for MyFormat { if text == "good" { result.insert( - "key".to_string(), + "key".to_owned(), Value::new(uri, ValueKind::String(text.into())), ); } else { - println!("Something went wrong in {:?}", uri); + println!("Something went wrong in {uri:?}"); } Ok(result) diff --git a/examples/hierarchical-env/main.rs b/examples/hierarchical-env/main.rs index ee1b69bd..08409494 100644 --- a/examples/hierarchical-env/main.rs +++ b/examples/hierarchical-env/main.rs @@ -6,5 +6,5 @@ fn main() { let settings = Settings::new(); // Print out our settings - println!("{:?}", settings); + println!("{settings:?}"); } diff --git a/examples/hierarchical-env/settings.rs b/examples/hierarchical-env/settings.rs index 65b5f875..3960a9a5 100644 --- a/examples/hierarchical-env/settings.rs +++ b/examples/hierarchical-env/settings.rs @@ -34,7 +34,7 @@ struct Braintree { #[derive(Debug, Deserialize)] #[allow(unused)] -pub struct Settings { +pub(crate) struct Settings { debug: bool, database: Database, sparkpost: Sparkpost, @@ -43,7 +43,7 @@ pub struct Settings { } impl Settings { - pub fn new() -> Result { + pub(crate) fn new() -> Result { let run_mode = env::var("RUN_MODE").unwrap_or_else(|_| "development".into()); let s = Config::builder() @@ -53,7 +53,7 @@ impl Settings { // Default to 'development' env // Note that this file is _optional_ .add_source( - File::with_name(&format!("examples/hierarchical-env/config/{}", run_mode)) + File::with_name(&format!("examples/hierarchical-env/config/{run_mode}")) .required(false), ) // Add in a local configuration file diff --git a/examples/watch/main.rs b/examples/watch/main.rs index ca83572c..7f35e869 100644 --- a/examples/watch/main.rs +++ b/examples/watch/main.rs @@ -28,7 +28,7 @@ fn show() { ); } -fn watch() { +fn watch() -> ! { // Create a channel to receive the events. let (tx, rx) = channel(); @@ -62,7 +62,7 @@ fn watch() { show(); } - Err(e) => println!("watch error: {:?}", e), + Err(e) => println!("watch error: {e:?}"), _ => { // Ignore event diff --git a/src/env.rs b/src/env.rs index d817d3a7..9848d69a 100644 --- a/src/env.rs +++ b/src/env.rs @@ -34,12 +34,12 @@ pub struct Environment { /// Optional directive to translate collected keys into a form that matches what serializers /// that the configuration would expect. For example if you have the `kebab-case` attribute - /// for your serde config types, you may want to pass Case::Kebab here. + /// for your serde config types, you may want to pass `Case::Kebab` here. #[cfg(feature = "convert-case")] - convert_case: Option, + convert_case: Option, - /// Optional character sequence that separates each env value into a vector. only works when try_parsing is set to true - /// Once set, you cannot have type String on the same environment, unless you set list_parse_keys. + /// Optional character sequence that separates each env value into a vector. only works when `try_parsing` is set to true + /// Once set, you cannot have type String on the same environment, unless you set `list_parse_keys`. list_separator: Option, /// A list of keys which should always be parsed as a list. If not set you can have only `Vec` or `String` (not both) in one environment. list_parse_keys: Option>, @@ -110,7 +110,7 @@ impl Environment { } } - /// See [Environment::with_prefix] + /// See [`Environment::with_prefix`] pub fn prefix(mut self, s: &str) -> Self { self.prefix = Some(s.into()); self @@ -141,7 +141,7 @@ impl Environment { self } - /// When set and try_parsing is true, then all environment variables will be parsed as [`Vec`] instead of [`String`]. + /// When set and `try_parsing` is true, then all environment variables will be parsed as [`Vec`] instead of [`String`]. /// See /// [`with_list_parse_key`](Self::with_list_parse_key) /// when you want to use [`Vec`] in combination with [`String`]. @@ -151,11 +151,11 @@ impl Environment { } /// Add a key which should be parsed as a list when collecting [`Value`]s from the environment. - /// Once list_separator is set, the type for string is [`Vec`]. + /// Once `list_separator` is set, the type for string is [`Vec`]. /// To switch the default type back to type Strings you need to provide the keys which should be [`Vec`] using this function. pub fn with_list_parse_key(mut self, key: &str) -> Self { if self.list_parse_keys.is_none() { - self.list_parse_keys = Some(vec![key.to_lowercase()]) + self.list_parse_keys = Some(vec![key.to_lowercase()]); } else { self.list_parse_keys = self.list_parse_keys.map(|mut keys| { keys.push(key.to_lowercase()); @@ -246,7 +246,7 @@ impl Source for Environment { let prefix_pattern = self .prefix .as_ref() - .map(|prefix| format!("{}{}", prefix, prefix_separator).to_lowercase()); + .map(|prefix| format!("{prefix}{prefix_separator}").to_lowercase()); let collector = |(key, value): (String, String)| { // Treat empty environment variables as unset @@ -295,7 +295,7 @@ impl Source for Environment { if keys.contains(&key) { let v: Vec = value .split(separator) - .map(|s| Value::new(Some(&uri), ValueKind::String(s.to_string()))) + .map(|s| Value::new(Some(&uri), ValueKind::String(s.to_owned()))) .collect(); ValueKind::Array(v) } else { @@ -304,7 +304,7 @@ impl Source for Environment { } else { let v: Vec = value .split(separator) - .map(|s| Value::new(Some(&uri), ValueKind::String(s.to_string()))) + .map(|s| Value::new(Some(&uri), ValueKind::String(s.to_owned()))) .collect(); ValueKind::Array(v) } diff --git a/src/error.rs b/src/error.rs index 3cb50e03..dc074b1f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -22,13 +22,13 @@ pub enum Unexpected { impl fmt::Display for Unexpected { fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> { match *self { - Unexpected::Bool(b) => write!(f, "boolean `{}`", b), - Unexpected::I64(i) => write!(f, "64-bit integer `{}`", i), - Unexpected::I128(i) => write!(f, "128-bit integer `{}`", i), - Unexpected::U64(i) => write!(f, "64-bit unsigned integer `{}`", i), - Unexpected::U128(i) => write!(f, "128-bit unsigned integer `{}`", i), - Unexpected::Float(v) => write!(f, "floating point `{}`", v), - Unexpected::Str(ref s) => write!(f, "string {:?}", s), + Unexpected::Bool(b) => write!(f, "boolean `{b}`"), + Unexpected::I64(i) => write!(f, "64-bit integer `{i}`"), + Unexpected::I128(i) => write!(f, "128-bit integer `{i}`"), + Unexpected::U64(i) => write!(f, "64-bit unsigned integer `{i}`"), + Unexpected::U128(i) => write!(f, "128-bit unsigned integer `{i}`"), + Unexpected::Float(v) => write!(f, "floating point `{v}`"), + Unexpected::Str(ref s) => write!(f, "string {s:?}"), Unexpected::Unit => write!(f, "unit value"), Unexpected::Seq => write!(f, "sequence"), Unexpected::Map => write!(f, "map"), @@ -142,7 +142,7 @@ impl ConfigError { } else { "" }; - format!("{}{}{}", segment, dot, key) + format!("{segment}{dot}{key}") }; match self { Self::Type { @@ -168,12 +168,12 @@ impl ConfigError { #[must_use] pub(crate) fn prepend_index(self, idx: usize) -> Self { - self.prepend(&format!("[{}]", idx), false) + self.prepend(&format!("[{idx}]"), false) } } /// Alias for a `Result` with the error type set to `ConfigError`. -pub type Result = result::Result; +pub(crate) type Result = result::Result; // Forward Debug to Display for readable panic! messages impl fmt::Debug for ConfigError { @@ -189,12 +189,12 @@ impl fmt::Display for ConfigError { ConfigError::PathParse(ref kind) => write!(f, "{}", kind.description()), - ConfigError::Message(ref s) => write!(f, "{}", s), + ConfigError::Message(ref s) => write!(f, "{s}"), - ConfigError::Foreign(ref cause) => write!(f, "{}", cause), + ConfigError::Foreign(ref cause) => write!(f, "{cause}"), ConfigError::NotFound(ref key) => { - write!(f, "configuration property {:?} not found", key) + write!(f, "configuration property {key:?} not found") } ConfigError::Type { @@ -203,24 +203,24 @@ impl fmt::Display for ConfigError { expected, ref key, } => { - write!(f, "invalid type: {}, expected {}", unexpected, expected)?; + write!(f, "invalid type: {unexpected}, expected {expected}")?; if let Some(ref key) = *key { - write!(f, " for key `{}`", key)?; + write!(f, " for key `{key}`")?; } if let Some(ref origin) = *origin { - write!(f, " in {}", origin)?; + write!(f, " in {origin}")?; } Ok(()) } ConfigError::FileParse { ref cause, ref uri } => { - write!(f, "{}", cause)?; + write!(f, "{cause}")?; if let Some(ref uri) = *uri { - write!(f, " in {}", uri)?; + write!(f, " in {uri}")?; } Ok(()) diff --git a/src/file/format/ini.rs b/src/file/format/ini.rs index 9295e60e..7394d6dd 100644 --- a/src/file/format/ini.rs +++ b/src/file/format/ini.rs @@ -5,7 +5,7 @@ use ini::Ini; use crate::map::Map; use crate::value::{Value, ValueKind}; -pub fn parse( +pub(crate) fn parse( uri: Option<&String>, text: &str, ) -> Result, Box> { diff --git a/src/file/format/json.rs b/src/file/format/json.rs index bd506f0d..9100b662 100644 --- a/src/file/format/json.rs +++ b/src/file/format/json.rs @@ -4,7 +4,7 @@ use crate::format; use crate::map::Map; use crate::value::{Value, ValueKind}; -pub fn parse( +pub(crate) fn parse( uri: Option<&String>, text: &str, ) -> Result, Box> { diff --git a/src/file/format/json5.rs b/src/file/format/json5.rs index 99003bd0..c0e557fc 100644 --- a/src/file/format/json5.rs +++ b/src/file/format/json5.rs @@ -6,7 +6,7 @@ use crate::value::{Value, ValueKind}; #[derive(serde::Deserialize, Debug)] #[serde(untagged)] -pub enum Val { +pub(crate) enum Val { Null, Boolean(bool), Integer(i64), @@ -16,7 +16,7 @@ pub enum Val { Object(Map), } -pub fn parse( +pub(crate) fn parse( uri: Option<&String>, text: &str, ) -> Result, Box> { diff --git a/src/file/format/mod.rs b/src/file/format/mod.rs index 025e98a9..1153a263 100644 --- a/src/file/format/mod.rs +++ b/src/file/format/mod.rs @@ -29,22 +29,22 @@ mod json5; /// File formats provided by the library. /// -/// Although it is possible to define custom formats using [`Format`] trait it is recommended to use FileFormat if possible. +/// Although it is possible to define custom formats using [`Format`] trait it is recommended to use `FileFormat` if possible. #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] pub enum FileFormat { /// TOML (parsed with toml) #[cfg(feature = "toml")] Toml, - /// JSON (parsed with serde_json) + /// JSON (parsed with `serde_json`) #[cfg(feature = "json")] Json, - /// YAML (parsed with yaml_rust) + /// YAML (parsed with `yaml_rust`) #[cfg(feature = "yaml")] Yaml, - /// INI (parsed with rust_ini) + /// INI (parsed with `rust_ini`) #[cfg(feature = "ini")] Ini, diff --git a/src/file/format/ron.rs b/src/file/format/ron.rs index 9ac81a9d..2911a73c 100644 --- a/src/file/format/ron.rs +++ b/src/file/format/ron.rs @@ -4,7 +4,7 @@ use crate::format; use crate::map::Map; use crate::value::{Value, ValueKind}; -pub fn parse( +pub(crate) fn parse( uri: Option<&String>, text: &str, ) -> Result, Box> { diff --git a/src/file/format/toml.rs b/src/file/format/toml.rs index 19b78044..26130779 100644 --- a/src/file/format/toml.rs +++ b/src/file/format/toml.rs @@ -4,7 +4,7 @@ use crate::format; use crate::map::Map; use crate::value::Value; -pub fn parse( +pub(crate) fn parse( uri: Option<&String>, text: &str, ) -> Result, Box> { diff --git a/src/file/format/yaml.rs b/src/file/format/yaml.rs index b35ba4d9..f535b3f5 100644 --- a/src/file/format/yaml.rs +++ b/src/file/format/yaml.rs @@ -8,7 +8,7 @@ use crate::format; use crate::map::Map; use crate::value::{Value, ValueKind}; -pub fn parse( +pub(crate) fn parse( uri: Option<&String>, text: &str, ) -> Result, Box> { diff --git a/src/file/mod.rs b/src/file/mod.rs index 0443a04b..0632043c 100644 --- a/src/file/mod.rs +++ b/src/file/mod.rs @@ -1,5 +1,5 @@ mod format; -pub mod source; +pub(crate) mod source; use std::fmt::Debug; use std::path::{Path, PathBuf}; @@ -39,7 +39,7 @@ pub trait FileStoredFormat: Format { fn file_extensions(&self) -> &'static [&'static str]; } -impl File +impl File where F: FileStoredFormat + 'static, { @@ -52,7 +52,7 @@ where } } -impl File +impl File where F: FileStoredFormat + 'static, { @@ -60,39 +60,39 @@ where Self { format: Some(format), required: true, - source: source::file::FileSourceFile::new(name.into()), + source: FileSourceFile::new(name.into()), } } } -impl File { +impl File { /// Given the basename of a file, will attempt to locate a file by setting its /// extension to a registered format. pub fn with_name(name: &str) -> Self { Self { format: None, required: true, - source: source::file::FileSourceFile::new(name.into()), + source: FileSourceFile::new(name.into()), } } } -impl<'a> From<&'a Path> for File { +impl<'a> From<&'a Path> for File { fn from(path: &'a Path) -> Self { Self { format: None, required: true, - source: source::file::FileSourceFile::new(path.to_path_buf()), + source: FileSourceFile::new(path.to_path_buf()), } } } -impl From for File { +impl From for File { fn from(path: PathBuf) -> Self { Self { format: None, required: true, - source: source::file::FileSourceFile::new(path), + source: FileSourceFile::new(path), } } } diff --git a/src/file/source/mod.rs b/src/file/source/mod.rs index 3c3d10ca..d017a765 100644 --- a/src/file/source/mod.rs +++ b/src/file/source/mod.rs @@ -1,5 +1,5 @@ -pub mod file; -pub mod string; +pub(crate) mod file; +pub(crate) mod string; use std::error::Error; use std::fmt::Debug; diff --git a/src/format.rs b/src/format.rs index 3d1ca335..8b4016d7 100644 --- a/src/format.rs +++ b/src/format.rs @@ -25,7 +25,7 @@ pub trait Format { } // Have a proper error fire if the root of a file is ever not a Table -pub fn extract_root_table( +pub(crate) fn extract_root_table( uri: Option<&String>, value: Value, ) -> Result, Box> { diff --git a/src/path/mod.rs b/src/path/mod.rs index 20d89e7e..730d0edf 100644 --- a/src/path/mod.rs +++ b/src/path/mod.rs @@ -7,7 +7,7 @@ use crate::value::{Value, ValueKind}; mod parser; #[derive(Debug, Eq, PartialEq, Clone, Hash)] -pub enum Expression { +pub(crate) enum Expression { Identifier(String), Child(Box, String), Subscript(Box, isize), @@ -30,7 +30,7 @@ fn sindex_to_uindex(index: isize, len: usize) -> usize { } impl Expression { - pub fn get(self, root: &Value) -> Option<&Value> { + pub(crate) fn get(self, root: &Value) -> Option<&Value> { match self { Self::Identifier(id) => { match root.kind { @@ -78,7 +78,7 @@ impl Expression { } } - pub fn get_mut<'a>(&self, root: &'a mut Value) -> Option<&'a mut Value> { + pub(crate) fn get_mut<'a>(&self, root: &'a mut Value) -> Option<&'a mut Value> { match *self { Self::Identifier(ref id) => match root.kind { ValueKind::Table(ref mut map) => map.get_mut(id), @@ -116,7 +116,7 @@ impl Expression { } } - pub fn get_mut_forcibly<'a>(&self, root: &'a mut Value) -> Option<&'a mut Value> { + pub(crate) fn get_mut_forcibly<'a>(&self, root: &'a mut Value) -> Option<&'a mut Value> { match *self { Self::Identifier(ref id) => match root.kind { ValueKind::Table(ref mut map) => Some( @@ -177,7 +177,7 @@ impl Expression { } } - pub fn set(&self, root: &mut Value, value: Value) { + pub(crate) fn set(&self, root: &mut Value, value: Value) { match *self { Self::Identifier(ref id) => { // Ensure that root is a table @@ -231,7 +231,7 @@ impl Expression { Self::Subscript(ref expr, index) => { if let Some(parent) = expr.get_mut_forcibly(root) { if !matches!(parent.kind, ValueKind::Array(_)) { - *parent = Vec::::new().into() + *parent = Vec::::new().into(); } if let ValueKind::Array(ref mut array) = parent.kind { diff --git a/src/path/parser.rs b/src/path/parser.rs index 8378121b..fbb8ba24 100644 --- a/src/path/parser.rs +++ b/src/path/parser.rs @@ -48,7 +48,7 @@ fn postfix<'a>(expr: Expression) -> impl FnMut(&'a str) -> IResult<&'a str, Expr alt((child, subscript)) } -pub fn from_str(input: &str) -> Result { +pub(crate) fn from_str(input: &str) -> Result { match ident(input) { Ok((mut rem, mut expr)) => { while !rem.is_empty() { @@ -73,7 +73,7 @@ pub fn from_str(input: &str) -> Result { } } -pub fn to_error_kind(e: Err>) -> ErrorKind { +pub(crate) fn to_error_kind(e: Err>) -> ErrorKind { match e { Err::Incomplete(_) => ErrorKind::Complete, Err::Failure(e) | Err::Error(e) => e.code, diff --git a/src/ser.rs b/src/ser.rs index 8d85cc09..ebf5c8db 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -20,7 +20,7 @@ enum SerKey { } /// An uninhabited type: no values like this can ever exist! -pub enum Unreachable {} +pub(crate) enum Unreachable {} /// Serializer for numbered sequences /// @@ -55,17 +55,13 @@ impl ConfigSerializer { let mut whole = match keys.next() { Some(SerKey::Named(s)) => s.clone(), - _ => { - return Err(ConfigError::Message( - "top level is not a struct".to_string(), - )) - } + _ => return Err(ConfigError::Message("top level is not a struct".to_owned())), }; for k in keys { match k { - SerKey::Named(s) => write!(whole, ".{}", s), - SerKey::Seq(i) => write!(whole, "[{}]", i), + SerKey::Named(s) => write!(whole, ".{s}"), + SerKey::Seq(i) => write!(whole, "[{i}]"), } .expect("write! to a string failed"); } @@ -74,7 +70,7 @@ impl ConfigSerializer { } fn push_key(&mut self, key: &str) { - self.keys.push(SerKey::Named(key.to_string())); + self.keys.push(SerKey::Named(key.to_owned())); } fn pop_key(&mut self) { @@ -150,7 +146,7 @@ impl<'a> ser::Serializer for &'a mut ConfigSerializer { } fn serialize_str(self, v: &str) -> Result { - self.serialize_primitive(v.to_string()) + self.serialize_primitive(v.to_owned()) } fn serialize_bytes(self, v: &[u8]) -> Result { @@ -288,7 +284,7 @@ impl<'a> ser::SerializeSeq for SeqSerializer<'a> { Some(SerKey::Seq(i)) => *i += 1, _ => { return Err(ConfigError::Message( - "config-rs internal error (ser._element but last not Seq!".to_string(), + "config-rs internal error (ser._element but last not Seq!".to_owned(), )) } }; @@ -418,7 +414,7 @@ impl<'a> ser::SerializeStructVariant for &'a mut ConfigSerializer { } } -pub struct StringKeySerializer; +pub(crate) struct StringKeySerializer; /// Define `$emthod`, `serialize_foo`, taking `$type` and serialising it via [`Display`] macro_rules! string_serialize_via_display { { $method:ident, $type:ty } => { @@ -481,7 +477,7 @@ impl ser::Serializer for StringKeySerializer { _variant_index: u32, variant: &str, ) -> Result { - Ok(variant.to_string()) + Ok(variant.to_owned()) } fn serialize_newtype_struct(self, _name: &str, value: &T) -> Result @@ -506,20 +502,19 @@ impl ser::Serializer for StringKeySerializer { fn serialize_seq(self, _len: Option) -> Result { Err(ConfigError::Message( - "seq can't serialize to string key".to_string(), + "seq can't serialize to string key".to_owned(), )) } fn serialize_tuple(self, _len: usize) -> Result { Err(ConfigError::Message( - "tuple can't serialize to string key".to_string(), + "tuple can't serialize to string key".to_owned(), )) } fn serialize_tuple_struct(self, name: &str, _len: usize) -> Result { Err(ConfigError::Message(format!( - "tuple struct {} can't serialize to string key", - name + "tuple struct {name} can't serialize to string key" ))) } @@ -531,21 +526,19 @@ impl ser::Serializer for StringKeySerializer { _len: usize, ) -> Result { Err(ConfigError::Message(format!( - "tuple variant {}::{} can't serialize to string key", - name, variant + "tuple variant {name}::{variant} can't serialize to string key" ))) } fn serialize_map(self, _len: Option) -> Result { Err(ConfigError::Message( - "map can't serialize to string key".to_string(), + "map can't serialize to string key".to_owned(), )) } fn serialize_struct(self, name: &str, _len: usize) -> Result { Err(ConfigError::Message(format!( - "struct {} can't serialize to string key", - name + "struct {name} can't serialize to string key" ))) } @@ -557,8 +550,7 @@ impl ser::Serializer for StringKeySerializer { _len: usize, ) -> Result { Err(ConfigError::Message(format!( - "struct variant {}::{} can't serialize to string key", - name, variant + "struct variant {name}::{variant} can't serialize to string key" ))) } } @@ -697,7 +689,7 @@ mod test { let test = Test { int: 1, - seq: vec!["a".to_string(), "b".to_string()], + seq: vec!["a".to_owned(), "b".to_owned()], }; let config = Config::try_from(&test).unwrap(); diff --git a/src/source.rs b/src/source.rs index 16e19385..7608fad6 100644 --- a/src/source.rs +++ b/src/source.rs @@ -33,7 +33,7 @@ fn set_value(cache: &mut Value, key: &str, value: &Value) { Ok(expr) => expr.set(cache, value.clone()), // Set diretly anyway - _ => path::Expression::Identifier(key.to_string()).set(cache, value.clone()), + _ => path::Expression::Identifier(key.to_owned()).set(cache, value.clone()), } } diff --git a/src/value.rs b/src/value.rs index fe00e7e9..95273f6b 100644 --- a/src/value.rs +++ b/src/value.rs @@ -26,8 +26,8 @@ pub enum ValueKind { Array(Array), } -pub type Array = Vec; -pub type Table = Map; +pub(crate) type Array = Vec; +pub(crate) type Table = Map; impl Default for ValueKind { fn default() -> Self { @@ -155,25 +155,25 @@ impl Display for ValueKind { use std::fmt::Write; match *self { - Self::String(ref value) => write!(f, "{}", value), - Self::Boolean(value) => write!(f, "{}", value), - Self::I64(value) => write!(f, "{}", value), - Self::I128(value) => write!(f, "{}", value), - Self::U64(value) => write!(f, "{}", value), - Self::U128(value) => write!(f, "{}", value), - Self::Float(value) => write!(f, "{}", value), + Self::String(ref value) => write!(f, "{value}"), + Self::Boolean(value) => write!(f, "{value}"), + Self::I64(value) => write!(f, "{value}"), + Self::I128(value) => write!(f, "{value}"), + Self::U64(value) => write!(f, "{value}"), + Self::U128(value) => write!(f, "{value}"), + Self::Float(value) => write!(f, "{value}"), Self::Nil => write!(f, "nil"), Self::Table(ref table) => { let mut s = String::new(); for (k, v) in table.iter() { - write!(s, "{} => {}, ", k, v)? + write!(s, "{k} => {v}, ")?; } write!(f, "{{ {s} }}") } Self::Array(ref array) => { let mut s = String::new(); for e in array.iter() { - write!(s, "{}, ", e)?; + write!(s, "{e}, ")?; } write!(f, "{s:?}") } @@ -786,7 +786,7 @@ impl<'de> Deserialize<'de> for Value { let num: i128 = value.try_into().map_err(|_| { E::invalid_type( ::serde::de::Unexpected::Other( - format!("integer `{}` as u128", value).as_str(), + format!("integer `{value}` as u128").as_str(), ), &self, ) diff --git a/tests/async_builder.rs b/tests/async_builder.rs index b91a1a3b..81c53bce 100644 --- a/tests/async_builder.rs +++ b/tests/async_builder.rs @@ -11,7 +11,7 @@ struct AsyncFile { /// This is a test only implementation to be used in tests impl AsyncFile { - pub fn new(path: String, format: FileFormat) -> Self { + pub(crate) fn new(path: String, format: FileFormat) -> Self { Self { path, format } } } diff --git a/tests/env.rs b/tests/env.rs index 9a0180fa..30aaedb2 100644 --- a/tests/env.rs +++ b/tests/env.rs @@ -10,7 +10,7 @@ fn test_default() { let environment = Environment::default(); assert!(environment.collect().unwrap().contains_key("a_b_c")); - }) + }); } #[test] @@ -19,7 +19,7 @@ fn test_prefix_is_removed_from_key() { let environment = Environment::with_prefix("B"); assert!(environment.collect().unwrap().contains_key("a_c")); - }) + }); } #[test] @@ -49,7 +49,7 @@ fn test_separator_behavior() { let environment = Environment::with_prefix("C").separator("_"); assert!(environment.collect().unwrap().contains_key("b.a")); - }) + }); } #[test] @@ -58,7 +58,7 @@ fn test_empty_value_is_ignored() { let environment = Environment::default().ignore_empty(true); assert!(!environment.collect().unwrap().contains_key("c_a_b")); - }) + }); } #[test] @@ -77,7 +77,7 @@ fn test_keep_prefix() { let environment = Environment::with_prefix("C").keep_prefix(true); assert!(environment.collect().unwrap().contains_key("c_a_b")); - }) + }); } #[test] @@ -86,7 +86,7 @@ fn test_custom_separator_behavior() { let environment = Environment::with_prefix("C").separator("."); assert!(environment.collect().unwrap().contains_key("b.a")); - }) + }); } #[test] @@ -97,7 +97,7 @@ fn test_custom_prefix_separator_behavior() { .prefix_separator("-"); assert!(environment.collect().unwrap().contains_key("b.a")); - }) + }); } #[test] @@ -127,7 +127,7 @@ fn test_parse_int() { let config: TestIntEnum = config.try_deserialize().unwrap(); assert!(matches!(config, TestIntEnum::Int(TestInt { int_val: 42 }))); - }) + }); } #[test] @@ -160,7 +160,7 @@ fn test_parse_uint() { config, TestUintEnum::Uint(TestUint { int_val: 42 }) )); - }) + }); } #[test] @@ -192,10 +192,10 @@ fn test_parse_float() { // can't use `matches!` because of float value match config { TestFloatEnum::Float(TestFloat { float_val }) => { - assert!(float_cmp::approx_eq!(f64, float_val, 42.3)) + assert!(float_cmp::approx_eq!(f64, float_val, 42.3)); } } - }) + }); } #[test] @@ -228,7 +228,7 @@ fn test_parse_bool() { config, TestBoolEnum::Bool(TestBool { bool_val: true }) )); - }) + }); } #[test] @@ -259,7 +259,7 @@ fn test_parse_off_int() { .unwrap(); config.try_deserialize::().unwrap(); - }) + }); } #[test] @@ -290,7 +290,7 @@ fn test_parse_off_float() { .unwrap(); config.try_deserialize::().unwrap(); - }) + }); } #[test] @@ -321,7 +321,7 @@ fn test_parse_off_bool() { .unwrap(); config.try_deserialize::().unwrap(); - }) + }); } #[test] @@ -352,7 +352,7 @@ fn test_parse_int_fail() { .unwrap(); config.try_deserialize::().unwrap(); - }) + }); } #[test] @@ -383,7 +383,7 @@ fn test_parse_float_fail() { .unwrap(); config.try_deserialize::().unwrap(); - }) + }); } #[test] @@ -414,7 +414,7 @@ fn test_parse_bool_fail() { .unwrap(); config.try_deserialize::().unwrap(); - }) + }); } #[test] @@ -466,7 +466,7 @@ fn test_parse_string_and_list() { } } }, - ) + ); } #[test] @@ -518,7 +518,7 @@ fn test_parse_string_and_list_ignore_list_parse_key_case() { } } }, - ) + ); } #[test] @@ -564,7 +564,7 @@ fn test_parse_nested_kebab() { let config = Config::builder().add_source(environment).build().unwrap(); - println!("{:#?}", config); + println!("{config:#?}"); let config: TestConfig = config.try_deserialize().unwrap(); @@ -573,7 +573,7 @@ fn test_parse_nested_kebab() { assert_eq!(config.value_with_multipart_name, "value1"); assert_eq!(config.inner_config.another_multipart_name, "value2"); }, - ) + ); } #[test] @@ -606,10 +606,10 @@ fn test_parse_string() { match config { TestStringEnum::String(TestString { string_val }) => { - assert_eq!(test_string, string_val) + assert_eq!(test_string, string_val); } } - }) + }); } #[test] @@ -642,10 +642,10 @@ fn test_parse_string_list() { match config { TestListEnum::StringList(TestList { string_list }) => { - assert_eq!(test_string, string_list) + assert_eq!(test_string, string_list); } } - }) + }); } #[test] @@ -681,7 +681,7 @@ fn test_parse_off_string() { assert_eq!(test_string, string_val_1); } } - }) + }); } #[test] diff --git a/tests/errors.rs b/tests/errors.rs index 1c3204c2..b04b0799 100644 --- a/tests/errors.rs +++ b/tests/errors.rs @@ -76,7 +76,7 @@ fn test_error_type_detached() { assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "invalid type: string \"fals\", expected a boolean".to_string() + "invalid type: string \"fals\", expected a boolean".to_owned() ); } @@ -148,7 +148,7 @@ fn test_error_enum_de() { let on_d = on_v.try_deserialize::(); assert_eq!( on_d.unwrap_err().to_string(), - "enum Diode does not have variant constructor on".to_string() + "enum Diode does not have variant constructor on".to_owned() ); let array_v: Value = vec![100, 100].into(); @@ -159,8 +159,8 @@ fn test_error_enum_de() { ); let confused_v: Value = [ - ("Brightness".to_string(), 100.into()), - ("Blinking".to_string(), vec![300, 700].into()), + ("Brightness".to_owned(), 100.into()), + ("Blinking".to_owned(), vec![300, 700].into()), ] .iter() .cloned() @@ -218,7 +218,7 @@ fn test_error_root_not_table() { Err(e) => match e { ConfigError::FileParse { cause, .. } => assert_eq!( "invalid type: boolean `false`, expected a map", - format!("{}", cause) + format!("{cause}") ), _ => panic!("Wrong error: {:?}", e), }, diff --git a/tests/file.rs b/tests/file.rs index 9e4469ae..e14c8265 100644 --- a/tests/file.rs +++ b/tests/file.rs @@ -20,7 +20,7 @@ fn test_file_required_not_found() { assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "configuration file \"tests/NoSettings\" not found".to_string() + "configuration file \"tests/NoSettings\" not found".to_owned() ); } @@ -44,7 +44,7 @@ fn test_file_auto_not_found() { assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "configuration file \"tests/NoSettings\" not found".to_string() + "configuration file \"tests/NoSettings\" not found".to_owned() ); } diff --git a/tests/file_ini.rs b/tests/file_ini.rs index 7561bff5..dcc5e89a 100644 --- a/tests/file_ini.rs +++ b/tests/file_ini.rs @@ -101,14 +101,14 @@ fn test_override_uppercase_value_for_struct() { assert_ne!(v.FOO, "FOO should be overridden"); assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } Err(e) => { if e.to_string().contains("missing field `FOO`") { assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } else { panic!("{}", e); @@ -130,9 +130,9 @@ fn test_override_lowercase_value_for_struct() { let values: StructSettings = cfg.try_deserialize().unwrap(); assert_eq!( values.foo, - "I have been overridden_with_lower_case".to_string() + "I have been overridden_with_lower_case".to_owned() ); - assert_ne!(values.foo, "I am bar".to_string()); + assert_ne!(values.foo, "I am bar".to_owned()); } #[test] @@ -148,7 +148,7 @@ fn test_override_uppercase_value_for_enums() { assert_eq!( val, - EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string()) + EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned()) ); } @@ -166,6 +166,6 @@ fn test_override_lowercase_value_for_enums() { assert_eq!( param, - EnumSettings::Bar("I have been overridden_with_lower_case".to_string()) + EnumSettings::Bar("I have been overridden_with_lower_case".to_owned()) ); } diff --git a/tests/file_json.rs b/tests/file_json.rs index 91cbc9bc..27ab61fe 100644 --- a/tests/file_json.rs +++ b/tests/file_json.rs @@ -43,7 +43,7 @@ fn test_file() { let s: Settings = c.try_deserialize().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); + assert_eq!(s.production, Some("false".to_owned())); assert_eq!(s.place.name, "Torre di Pisa"); assert!(s.place.longitude.approx_eq_ulps(&43.722_498_5, 2)); assert!(s.place.latitude.approx_eq_ulps(&10.397_052_2, 2)); @@ -52,15 +52,15 @@ fn test_file() { assert_eq!(s.place.rating, Some(4.5)); assert_eq!(s.place.telephone, None); assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); + assert_eq!(s.elements[3], "4".to_owned()); if cfg!(feature = "preserve_order") { assert_eq!( s.place .creator .into_iter() - .collect::>(), + .collect::>(), vec![ - ("name".to_string(), "John Smith".into()), + ("name".to_owned(), "John Smith".into()), ("username".into(), "jsmith".into()), ("email".into(), "jsmith@localhost".into()), ] @@ -68,7 +68,7 @@ fn test_file() { } else { assert_eq!( s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + "John Smith".to_owned() ); } } @@ -147,15 +147,15 @@ fn test_override_uppercase_value_for_struct() { assert_ne!(v.FOO, "FOO should be overridden"); assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } Err(e) => { if e.to_string().contains("missing field `FOO`") { - println!("triggered error {:?}", e); + println!("triggered error {e:?}"); assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } else { panic!("{}", e); @@ -177,9 +177,9 @@ fn test_override_lowercase_value_for_struct() { let values: StructSettings = cfg.try_deserialize().unwrap(); assert_eq!( values.foo, - "I have been overridden_with_lower_case".to_string() + "I have been overridden_with_lower_case".to_owned() ); - assert_ne!(values.foo, "I am bar".to_string()); + assert_ne!(values.foo, "I am bar".to_owned()); } #[test] @@ -195,7 +195,7 @@ fn test_override_uppercase_value_for_enums() { assert_eq!( val, - EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string()) + EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned()) ); } @@ -213,6 +213,6 @@ fn test_override_lowercase_value_for_enums() { assert_eq!( param, - EnumSettings::Bar("I have been overridden_with_lower_case".to_string()) + EnumSettings::Bar("I have been overridden_with_lower_case".to_owned()) ); } diff --git a/tests/file_json5.rs b/tests/file_json5.rs index bdeb3eaf..f0c12676 100644 --- a/tests/file_json5.rs +++ b/tests/file_json5.rs @@ -42,7 +42,7 @@ fn test_file() { let s: Settings = c.try_deserialize().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); + assert_eq!(s.production, Some("false".to_owned())); assert_eq!(s.place.name, "Torre di Pisa"); assert!(s.place.longitude.approx_eq_ulps(&43.722_498_5, 2)); assert!(s.place.latitude.approx_eq_ulps(&10.397_052_2, 2)); @@ -51,15 +51,15 @@ fn test_file() { assert_eq!(s.place.rating, Some(4.5)); assert_eq!(s.place.telephone, None); assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); + assert_eq!(s.elements[3], "4".to_owned()); if cfg!(feature = "preserve_order") { assert_eq!( s.place .creator .into_iter() - .collect::>(), + .collect::>(), vec![ - ("name".to_string(), "John Smith".into()), + ("name".to_owned(), "John Smith".into()), ("username".into(), "jsmith".into()), ("email".into(), "jsmith@localhost".into()), ] @@ -67,7 +67,7 @@ fn test_file() { } else { assert_eq!( s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + "John Smith".to_owned() ); } } @@ -125,14 +125,14 @@ fn test_override_uppercase_value_for_struct() { assert_ne!(v.FOO, "FOO should be overridden"); assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } Err(e) => { if e.to_string().contains("missing field `FOO`") { assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } else { panic!("{}", e); @@ -154,9 +154,9 @@ fn test_override_lowercase_value_for_struct() { let values: StructSettings = cfg.try_deserialize().unwrap(); assert_eq!( values.foo, - "I have been overridden_with_lower_case".to_string() + "I have been overridden_with_lower_case".to_owned() ); - assert_ne!(values.foo, "I am bar".to_string()); + assert_ne!(values.foo, "I am bar".to_owned()); } #[test] @@ -172,7 +172,7 @@ fn test_override_uppercase_value_for_enums() { assert_eq!( val, - EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string()) + EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned()) ); } @@ -190,6 +190,6 @@ fn test_override_lowercase_value_for_enums() { assert_eq!( param, - EnumSettings::Bar("I have been overridden_with_lower_case".to_string()) + EnumSettings::Bar("I have been overridden_with_lower_case".to_owned()) ); } diff --git a/tests/file_ron.rs b/tests/file_ron.rs index 9f1ea356..ae3ff973 100644 --- a/tests/file_ron.rs +++ b/tests/file_ron.rs @@ -44,7 +44,7 @@ fn test_file() { let s: Settings = c.try_deserialize().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); + assert_eq!(s.production, Some("false".to_owned())); assert_eq!(s.place.initials, ('T', 'P')); assert_eq!(s.place.name, "Torre di Pisa"); assert!(s.place.longitude.approx_eq_ulps(&43.722_498_5, 2)); @@ -54,15 +54,15 @@ fn test_file() { assert_eq!(s.place.rating, Some(4.5)); assert_eq!(s.place.telephone, None); assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); + assert_eq!(s.elements[3], "4".to_owned()); if cfg!(feature = "preserve_order") { assert_eq!( s.place .creator .into_iter() - .collect::>(), + .collect::>(), vec![ - ("name".to_string(), "John Smith".into()), + ("name".to_owned(), "John Smith".into()), ("username".into(), "jsmith".into()), ("email".into(), "jsmith@localhost".into()), ] @@ -70,7 +70,7 @@ fn test_file() { } else { assert_eq!( s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + "John Smith".to_owned() ); } } @@ -125,14 +125,14 @@ fn test_override_uppercase_value_for_struct() { assert_ne!(v.FOO, "FOO should be overridden"); assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } Err(e) => { if e.to_string().contains("missing field `FOO`") { assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } else { panic!("{}", e); @@ -154,9 +154,9 @@ fn test_override_lowercase_value_for_struct() { let values: StructSettings = cfg.try_deserialize().unwrap(); assert_eq!( values.foo, - "I have been overridden_with_lower_case".to_string() + "I have been overridden_with_lower_case".to_owned() ); - assert_ne!(values.foo, "I am bar".to_string()); + assert_ne!(values.foo, "I am bar".to_owned()); } #[test] @@ -172,7 +172,7 @@ fn test_override_uppercase_value_for_enums() { assert_eq!( val, - EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string()) + EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned()) ); } @@ -190,6 +190,6 @@ fn test_override_lowercase_value_for_enums() { assert_eq!( param, - EnumSettings::Bar("I have been overridden_with_lower_case".to_string()) + EnumSettings::Bar("I have been overridden_with_lower_case".to_owned()) ); } diff --git a/tests/file_toml.rs b/tests/file_toml.rs index e0ec626e..2e909e4f 100644 --- a/tests/file_toml.rs +++ b/tests/file_toml.rs @@ -50,7 +50,7 @@ fn test_file() { let s: Settings = c.try_deserialize().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); + assert_eq!(s.production, Some("false".to_owned())); assert_eq!(s.code, AsciiCode(53)); assert_eq!(s.place.number, PlaceNumber(1)); assert_eq!(s.place.name, "Torre di Pisa"); @@ -61,15 +61,15 @@ fn test_file() { assert_eq!(s.place.rating, Some(4.5)); assert_eq!(s.place.telephone, None); assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); + assert_eq!(s.elements[3], "4".to_owned()); if cfg!(feature = "preserve_order") { assert_eq!( s.place .creator .into_iter() - .collect::>(), + .collect::>(), vec![ - ("name".to_string(), "John Smith".into()), + ("name".to_owned(), "John Smith".into()), ("username".into(), "jsmith".into()), ("email".into(), "jsmith@localhost".into()), ] @@ -77,7 +77,7 @@ fn test_file() { } else { assert_eq!( s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + "John Smith".to_owned() ); } } @@ -129,14 +129,14 @@ fn test_override_uppercase_value_for_struct() { assert_ne!(v.FOO, "FOO should be overridden"); assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } Err(e) => { if e.to_string().contains("missing field `FOO`") { assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } else { panic!("{}", e); @@ -158,9 +158,9 @@ fn test_override_lowercase_value_for_struct() { let values: StructSettings = cfg.try_deserialize().unwrap(); assert_eq!( values.bar, - "I have been overridden_with_lower_case".to_string() + "I have been overridden_with_lower_case".to_owned() ); - assert_ne!(values.bar, "I am bar".to_string()); + assert_ne!(values.bar, "I am bar".to_owned()); } #[test] @@ -177,7 +177,7 @@ fn test_override_uppercase_value_for_enums() { assert_eq!( values, - EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string()) + EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned()) ); } @@ -195,6 +195,6 @@ fn test_override_lowercase_value_for_enums() { assert_eq!( values, - EnumSettings::Bar("I have been overridden_with_lower_case".to_string()) + EnumSettings::Bar("I have been overridden_with_lower_case".to_owned()) ); } diff --git a/tests/file_yaml.rs b/tests/file_yaml.rs index b961c2a6..780f326e 100644 --- a/tests/file_yaml.rs +++ b/tests/file_yaml.rs @@ -43,7 +43,7 @@ fn test_file() { let s: Settings = c.try_deserialize().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); + assert_eq!(s.production, Some("false".to_owned())); assert_eq!(s.place.name, "Torre di Pisa"); assert!(s.place.longitude.approx_eq_ulps(&43.722_498_5, 2)); assert!(s.place.latitude.approx_eq_ulps(&10.397_052_2, 2)); @@ -52,15 +52,15 @@ fn test_file() { assert_eq!(s.place.rating, Some(4.5)); assert_eq!(s.place.telephone, None); assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); + assert_eq!(s.elements[3], "4".to_owned()); if cfg!(feature = "preserve_order") { assert_eq!( s.place .creator .into_iter() - .collect::>(), + .collect::>(), vec![ - ("name".to_string(), "John Smith".into()), + ("name".to_owned(), "John Smith".into()), ("username".into(), "jsmith".into()), ("email".into(), "jsmith@localhost".into()), ] @@ -68,7 +68,7 @@ fn test_file() { } else { assert_eq!( s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + "John Smith".to_owned() ); } } @@ -156,15 +156,15 @@ fn test_override_uppercase_value_for_struct() { assert_ne!(v.FOO, "FOO should be overridden"); assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } Err(e) => { if e.to_string().contains("missing field `FOO`") { - println!("triggered error {:?}", e); + println!("triggered error {e:?}"); assert_eq!( lower_settings.foo, - "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string() + "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned() ); } else { panic!("{}", e); @@ -186,9 +186,9 @@ fn test_override_lowercase_value_for_struct() { let values: StructSettings = cfg.try_deserialize().unwrap(); assert_eq!( values.bar, - "I have been overridden_with_lower_case".to_string() + "I have been overridden_with_lower_case".to_owned() ); - assert_ne!(values.bar, "I am bar".to_string()); + assert_ne!(values.bar, "I am bar".to_owned()); } #[test] @@ -204,7 +204,7 @@ fn test_override_uppercase_value_for_enums() { assert_eq!( values, - EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_string()) + EnumSettings::Bar("I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned()) ); } @@ -222,6 +222,6 @@ fn test_override_lowercase_value_for_enums() { assert_eq!( values, - EnumSettings::Bar("I have been overridden_with_lower_case".to_string()) + EnumSettings::Bar("I have been overridden_with_lower_case".to_owned()) ); } diff --git a/tests/get.rs b/tests/get.rs index fc532073..83bc76bc 100644 --- a/tests/get.rs +++ b/tests/get.rs @@ -40,7 +40,7 @@ fn test_not_found() { assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "configuration property \"not_found\" not found".to_string() + "configuration property \"not_found\" not found".to_owned() ); } @@ -57,22 +57,22 @@ fn test_scalar_type_loose() { let c = make(); assert_eq!(c.get("debug").ok(), Some(true)); - assert_eq!(c.get("debug").ok(), Some("true".to_string())); + assert_eq!(c.get("debug").ok(), Some("true".to_owned())); assert_eq!(c.get("debug").ok(), Some(1)); assert_eq!(c.get("debug").ok(), Some(1.0)); assert_eq!(c.get("debug_s").ok(), Some(true)); - assert_eq!(c.get("debug_s").ok(), Some("true".to_string())); + assert_eq!(c.get("debug_s").ok(), Some("true".to_owned())); assert_eq!(c.get("debug_s").ok(), Some(1)); assert_eq!(c.get("debug_s").ok(), Some(1.0)); assert_eq!(c.get("production").ok(), Some(false)); - assert_eq!(c.get("production").ok(), Some("false".to_string())); + assert_eq!(c.get("production").ok(), Some("false".to_owned())); assert_eq!(c.get("production").ok(), Some(0)); assert_eq!(c.get("production").ok(), Some(0.0)); assert_eq!(c.get("production_s").ok(), Some(false)); - assert_eq!(c.get("production_s").ok(), Some("false".to_string())); + assert_eq!(c.get("production_s").ok(), Some("false".to_owned())); assert_eq!(c.get("production_s").ok(), Some(0)); assert_eq!(c.get("production_s").ok(), Some(0.0)); } @@ -84,7 +84,7 @@ fn test_get_scalar_path() { assert_eq!(c.get("place.favorite").ok(), Some(false)); assert_eq!( c.get("place.creator.name").ok(), - Some("John Smith".to_string()) + Some("John Smith".to_owned()) ); } @@ -93,10 +93,10 @@ fn test_get_scalar_path_subscript() { let c = make(); assert_eq!(c.get("arr[2]").ok(), Some(3)); - assert_eq!(c.get("items[0].name").ok(), Some("1".to_string())); - assert_eq!(c.get("items[1].name").ok(), Some("2".to_string())); - assert_eq!(c.get("items[-1].name").ok(), Some("2".to_string())); - assert_eq!(c.get("items[-2].name").ok(), Some("1".to_string())); + assert_eq!(c.get("items[0].name").ok(), Some("1".to_owned())); + assert_eq!(c.get("items[1].name").ok(), Some("2".to_owned())); + assert_eq!(c.get("items[-1].name").ok(), Some("2".to_owned())); + assert_eq!(c.get("items[-2].name").ok(), Some("1".to_owned())); } #[test] @@ -107,7 +107,7 @@ fn test_map() { assert_eq!(m.len(), 8); assert_eq!( m["name"].clone().into_string().unwrap(), - "Torre di Pisa".to_string() + "Torre di Pisa".to_owned() ); assert_eq!(m["reviews"].clone().into_int().unwrap(), 3866); } @@ -121,14 +121,14 @@ fn test_map_str() { assert_eq!( m.into_iter().collect::>(), vec![ - ("name".to_string(), "John Smith".to_string()), - ("username".to_string(), "jsmith".to_string()), - ("email".to_string(), "jsmith@localhost".to_string()), + ("name".to_owned(), "John Smith".to_owned()), + ("username".to_owned(), "jsmith".to_owned()), + ("email".to_owned(), "jsmith@localhost".to_owned()), ] ); } else { assert_eq!(m.len(), 3); - assert_eq!(m["name"], "John Smith".to_string()); + assert_eq!(m["name"], "John Smith".to_owned()); } } @@ -145,7 +145,7 @@ fn test_map_struct() { assert_eq!(s.place.len(), 8); assert_eq!( s.place["name"].clone().into_string().unwrap(), - "Torre di Pisa".to_string() + "Torre di Pisa".to_owned() ); assert_eq!(s.place["reviews"].clone().into_int().unwrap(), 3866); } @@ -158,7 +158,7 @@ fn test_file_struct() { let s: Settings = c.try_deserialize().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); + assert_eq!(s.production, Some("false".to_owned())); assert_eq!(s.place.name, "Torre di Pisa"); assert!(s.place.longitude.approx_eq_ulps(&43.722_498_5, 2)); assert!(s.place.latitude.approx_eq_ulps(&10.397_052_2, 2)); @@ -206,7 +206,7 @@ fn test_struct_array() { let s: Settings = c.try_deserialize().unwrap(); assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); + assert_eq!(s.elements[3], "4".to_owned()); } #[test] diff --git a/tests/legacy/errors.rs b/tests/legacy/errors.rs index 191e85eb..ca514e81 100644 --- a/tests/legacy/errors.rs +++ b/tests/legacy/errors.rs @@ -42,7 +42,7 @@ fn test_error_type_detached() { assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "invalid type: string \"fals\", expected a boolean".to_string() + "invalid type: string \"fals\", expected a boolean".to_owned() ); } @@ -60,7 +60,7 @@ fn test_error_enum_de() { let on_d = on_v.try_deserialize::(); assert_eq!( on_d.unwrap_err().to_string(), - "enum Diode does not have variant constructor on".to_string() + "enum Diode does not have variant constructor on".to_owned() ); let array_v: Value = vec![100, 100].into(); @@ -71,8 +71,8 @@ fn test_error_enum_de() { ); let confused_v: Value = [ - ("Brightness".to_string(), 100.into()), - ("Blinking".to_string(), vec![300, 700].into()), + ("Brightness".to_owned(), 100.into()), + ("Blinking".to_owned(), vec![300, 700].into()), ] .iter() .cloned() diff --git a/tests/legacy/file.rs b/tests/legacy/file.rs index 59006465..11cedee1 100644 --- a/tests/legacy/file.rs +++ b/tests/legacy/file.rs @@ -18,7 +18,7 @@ fn test_file_required_not_found() { assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "configuration file \"tests/NoSettings\" not found".to_string() + "configuration file \"tests/NoSettings\" not found".to_owned() ); } @@ -40,7 +40,7 @@ fn test_file_auto_not_found() { assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "configuration file \"tests/NoSettings\" not found".to_string() + "configuration file \"tests/NoSettings\" not found".to_owned() ); } diff --git a/tests/legacy/file_json.rs b/tests/legacy/file_json.rs index 72fd5ebb..43c6fdc5 100644 --- a/tests/legacy/file_json.rs +++ b/tests/legacy/file_json.rs @@ -44,7 +44,7 @@ fn test_file() { let s: Settings = c.try_deserialize().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); + assert_eq!(s.production, Some("false".to_owned())); assert_eq!(s.place.name, "Torre di Pisa"); assert!(s.place.longitude.approx_eq_ulps(&43.722_498_5, 2)); assert!(s.place.latitude.approx_eq_ulps(&10.397_052_2, 2)); @@ -53,15 +53,15 @@ fn test_file() { assert_eq!(s.place.rating, Some(4.5)); assert_eq!(s.place.telephone, None); assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); + assert_eq!(s.elements[3], "4".to_owned()); if cfg!(feature = "preserve_order") { assert_eq!( s.place .creator .into_iter() - .collect::>(), + .collect::>(), vec![ - ("name".to_string(), "John Smith".into()), + ("name".to_owned(), "John Smith".into()), ("username".into(), "jsmith".into()), ("email".into(), "jsmith@localhost".into()), ] @@ -69,7 +69,7 @@ fn test_file() { } else { assert_eq!( s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + "John Smith".to_owned() ); } } diff --git a/tests/legacy/file_ron.rs b/tests/legacy/file_ron.rs index 7f31c0e9..1f069f32 100644 --- a/tests/legacy/file_ron.rs +++ b/tests/legacy/file_ron.rs @@ -44,7 +44,7 @@ fn test_file() { let s: Settings = c.try_deserialize().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); + assert_eq!(s.production, Some("false".to_owned())); assert_eq!(s.place.initials, ('T', 'P')); assert_eq!(s.place.name, "Torre di Pisa"); assert!(s.place.longitude.approx_eq_ulps(&43.722_498_5, 2)); @@ -54,15 +54,15 @@ fn test_file() { assert_eq!(s.place.rating, Some(4.5)); assert_eq!(s.place.telephone, None); assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); + assert_eq!(s.elements[3], "4".to_owned()); if cfg!(feature = "preserve_order") { assert_eq!( s.place .creator .into_iter() - .collect::>(), + .collect::>(), vec![ - ("name".to_string(), "John Smith".into()), + ("name".to_owned(), "John Smith".into()), ("username".into(), "jsmith".into()), ("email".into(), "jsmith@localhost".into()), ] @@ -70,7 +70,7 @@ fn test_file() { } else { assert_eq!( s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + "John Smith".to_owned() ); } } diff --git a/tests/legacy/file_toml.rs b/tests/legacy/file_toml.rs index 2ecdb01d..a26f25ce 100644 --- a/tests/legacy/file_toml.rs +++ b/tests/legacy/file_toml.rs @@ -51,7 +51,7 @@ fn test_file() { let s: Settings = c.try_deserialize().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); + assert_eq!(s.production, Some("false".to_owned())); assert_eq!(s.code, AsciiCode(53)); assert_eq!(s.place.number, PlaceNumber(1)); assert_eq!(s.place.name, "Torre di Pisa"); @@ -62,15 +62,15 @@ fn test_file() { assert_eq!(s.place.rating, Some(4.5)); assert_eq!(s.place.telephone, None); assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); + assert_eq!(s.elements[3], "4".to_owned()); if cfg!(feature = "preserve_order") { assert_eq!( s.place .creator .into_iter() - .collect::>(), + .collect::>(), vec![ - ("name".to_string(), "John Smith".into()), + ("name".to_owned(), "John Smith".into()), ("username".into(), "jsmith".into()), ("email".into(), "jsmith@localhost".into()), ] @@ -78,7 +78,7 @@ fn test_file() { } else { assert_eq!( s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + "John Smith".to_owned() ); } } diff --git a/tests/legacy/file_yaml.rs b/tests/legacy/file_yaml.rs index 21d41384..82920b37 100644 --- a/tests/legacy/file_yaml.rs +++ b/tests/legacy/file_yaml.rs @@ -44,7 +44,7 @@ fn test_file() { let s: Settings = c.try_deserialize().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); + assert_eq!(s.production, Some("false".to_owned())); assert_eq!(s.place.name, "Torre di Pisa"); assert!(s.place.longitude.approx_eq_ulps(&43.722_498_5, 2)); assert!(s.place.latitude.approx_eq_ulps(&10.397_052_2, 2)); @@ -53,15 +53,15 @@ fn test_file() { assert_eq!(s.place.rating, Some(4.5)); assert_eq!(s.place.telephone, None); assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); + assert_eq!(s.elements[3], "4".to_owned()); if cfg!(feature = "preserve_order") { assert_eq!( s.place .creator .into_iter() - .collect::>(), + .collect::>(), vec![ - ("name".to_string(), "John Smith".into()), + ("name".to_owned(), "John Smith".into()), ("username".into(), "jsmith".into()), ("email".into(), "jsmith@localhost".into()), ] @@ -69,7 +69,7 @@ fn test_file() { } else { assert_eq!( s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + "John Smith".to_owned() ); } } diff --git a/tests/legacy/get.rs b/tests/legacy/get.rs index 837ad9e1..e073a51b 100644 --- a/tests/legacy/get.rs +++ b/tests/legacy/get.rs @@ -40,7 +40,7 @@ fn test_not_found() { assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "configuration property \"not_found\" not found".to_string() + "configuration property \"not_found\" not found".to_owned() ); } @@ -57,22 +57,22 @@ fn test_scalar_type_loose() { let c = make(); assert_eq!(c.get("debug").ok(), Some(true)); - assert_eq!(c.get("debug").ok(), Some("true".to_string())); + assert_eq!(c.get("debug").ok(), Some("true".to_owned())); assert_eq!(c.get("debug").ok(), Some(1)); assert_eq!(c.get("debug").ok(), Some(1.0)); assert_eq!(c.get("debug_s").ok(), Some(true)); - assert_eq!(c.get("debug_s").ok(), Some("true".to_string())); + assert_eq!(c.get("debug_s").ok(), Some("true".to_owned())); assert_eq!(c.get("debug_s").ok(), Some(1)); assert_eq!(c.get("debug_s").ok(), Some(1.0)); assert_eq!(c.get("production").ok(), Some(false)); - assert_eq!(c.get("production").ok(), Some("false".to_string())); + assert_eq!(c.get("production").ok(), Some("false".to_owned())); assert_eq!(c.get("production").ok(), Some(0)); assert_eq!(c.get("production").ok(), Some(0.0)); assert_eq!(c.get("production_s").ok(), Some(false)); - assert_eq!(c.get("production_s").ok(), Some("false".to_string())); + assert_eq!(c.get("production_s").ok(), Some("false".to_owned())); assert_eq!(c.get("production_s").ok(), Some(0)); assert_eq!(c.get("production_s").ok(), Some(0.0)); } @@ -84,7 +84,7 @@ fn test_get_scalar_path() { assert_eq!(c.get("place.favorite").ok(), Some(false)); assert_eq!( c.get("place.creator.name").ok(), - Some("John Smith".to_string()) + Some("John Smith".to_owned()) ); } @@ -93,10 +93,10 @@ fn test_get_scalar_path_subscript() { let c = make(); assert_eq!(c.get("arr[2]").ok(), Some(3)); - assert_eq!(c.get("items[0].name").ok(), Some("1".to_string())); - assert_eq!(c.get("items[1].name").ok(), Some("2".to_string())); - assert_eq!(c.get("items[-1].name").ok(), Some("2".to_string())); - assert_eq!(c.get("items[-2].name").ok(), Some("1".to_string())); + assert_eq!(c.get("items[0].name").ok(), Some("1".to_owned())); + assert_eq!(c.get("items[1].name").ok(), Some("2".to_owned())); + assert_eq!(c.get("items[-1].name").ok(), Some("2".to_owned())); + assert_eq!(c.get("items[-2].name").ok(), Some("1".to_owned())); } #[test] @@ -107,7 +107,7 @@ fn test_map() { assert_eq!(m.len(), 8); assert_eq!( m["name"].clone().into_string().unwrap(), - "Torre di Pisa".to_string() + "Torre di Pisa".to_owned() ); assert_eq!(m["reviews"].clone().into_int().unwrap(), 3866); } @@ -121,14 +121,14 @@ fn test_map_str() { assert_eq!( m.into_iter().collect::>(), vec![ - ("name".to_string(), "John Smith".to_string()), - ("username".to_string(), "jsmith".to_string()), - ("email".to_string(), "jsmith@localhost".to_string()), + ("name".to_owned(), "John Smith".to_owned()), + ("username".to_owned(), "jsmith".to_owned()), + ("email".to_owned(), "jsmith@localhost".to_owned()), ] ); } else { assert_eq!(m.len(), 3); - assert_eq!(m["name"], "John Smith".to_string()); + assert_eq!(m["name"], "John Smith".to_owned()); } } @@ -145,7 +145,7 @@ fn test_map_struct() { assert_eq!(s.place.len(), 8); assert_eq!( s.place["name"].clone().into_string().unwrap(), - "Torre di Pisa".to_string() + "Torre di Pisa".to_owned() ); assert_eq!(s.place["reviews"].clone().into_int().unwrap(), 3866); } @@ -158,7 +158,7 @@ fn test_file_struct() { let s: Settings = c.try_deserialize().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); + assert_eq!(s.production, Some("false".to_owned())); assert_eq!(s.place.name, "Torre di Pisa"); assert!(s.place.longitude.approx_eq_ulps(&43.722_498_5, 2)); assert!(s.place.latitude.approx_eq_ulps(&10.397_052_2, 2)); @@ -206,7 +206,7 @@ fn test_struct_array() { let s: Settings = c.try_deserialize().unwrap(); assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); + assert_eq!(s.elements[3], "4".to_owned()); } #[test] diff --git a/tests/legacy/merge.rs b/tests/legacy/merge.rs index 74463d66..fca5e168 100644 --- a/tests/legacy/merge.rs +++ b/tests/legacy/merge.rs @@ -26,15 +26,15 @@ fn test_merge() { assert_eq!( m.into_iter().collect::>(), vec![ - ("name".to_string(), "Somebody New".to_string()), - ("username".to_string(), "jsmith".to_string()), - ("email".to_string(), "jsmith@localhost".to_string()), + ("name".to_owned(), "Somebody New".to_owned()), + ("username".to_owned(), "jsmith".to_owned()), + ("email".to_owned(), "jsmith@localhost".to_owned()), ] ); } else { assert_eq!( c.get("place.creator.name").ok(), - Some("Somebody New".to_string()) + Some("Somebody New".to_owned()) ); } } diff --git a/tests/legacy/set.rs b/tests/legacy/set.rs index 169e462a..a16241c1 100644 --- a/tests/legacy/set.rs +++ b/tests/legacy/set.rs @@ -50,16 +50,13 @@ fn test_set_arr_path() { c.set("items[0].name", "Ivan").unwrap(); - assert_eq!(c.get("items[0].name").ok(), Some("Ivan".to_string())); + assert_eq!(c.get("items[0].name").ok(), Some("Ivan".to_owned())); c.set("data[0].things[1].name", "foo").unwrap(); c.set("data[0].things[1].value", 42).unwrap(); c.set("data[1]", 0).unwrap(); - assert_eq!( - c.get("data[0].things[1].name").ok(), - Some("foo".to_string()) - ); + assert_eq!(c.get("data[0].things[1].name").ok(), Some("foo".to_owned())); assert_eq!(c.get("data[0].things[1].value").ok(), Some(42)); assert_eq!(c.get("data[1]").ok(), Some(0)); @@ -68,11 +65,11 @@ fn test_set_arr_path() { c.set("items[0].name", "John").unwrap(); - assert_eq!(c.get("items[0].name").ok(), Some("John".to_string())); + assert_eq!(c.get("items[0].name").ok(), Some("John".to_owned())); c.set("items[2]", "George").unwrap(); - assert_eq!(c.get("items[2]").ok(), Some("George".to_string())); + assert_eq!(c.get("items[2]").ok(), Some("George".to_owned())); } #[cfg(feature = "toml")] diff --git a/tests/merge.rs b/tests/merge.rs index 0469064f..8030bec8 100644 --- a/tests/merge.rs +++ b/tests/merge.rs @@ -23,15 +23,15 @@ fn test_merge() { assert_eq!( m.into_iter().collect::>(), vec![ - ("name".to_string(), "Somebody New".to_string()), - ("username".to_string(), "jsmith".to_string()), - ("email".to_string(), "jsmith@localhost".to_string()), + ("name".to_owned(), "Somebody New".to_owned()), + ("username".to_owned(), "jsmith".to_owned()), + ("email".to_owned(), "jsmith@localhost".to_owned()), ] ); } else { assert_eq!( c.get("place.creator.name").ok(), - Some("Somebody New".to_string()) + Some("Somebody New".to_owned()) ); } } diff --git a/tests/set.rs b/tests/set.rs index 59b5b849..0a5ac8ed 100644 --- a/tests/set.rs +++ b/tests/set.rs @@ -63,14 +63,14 @@ fn test_set_arr_path() { .build() .unwrap(); - assert_eq!(config.get("items[0].name").ok(), Some("Ivan".to_string())); + assert_eq!(config.get("items[0].name").ok(), Some("Ivan".to_owned())); assert_eq!( config.get("data[0].things[1].name").ok(), - Some("foo".to_string()) + Some("foo".to_owned()) ); assert_eq!(config.get("data[0].things[1].value").ok(), Some(42)); assert_eq!(config.get("data[1]").ok(), Some(0)); - assert_eq!(config.get("items[2]").ok(), Some("George".to_string())); + assert_eq!(config.get("items[2]").ok(), Some("George".to_owned())); } #[cfg(feature = "toml")] diff --git a/tests/unsigned_int.rs b/tests/unsigned_int.rs index e870c8a1..4d0a6f50 100644 --- a/tests/unsigned_int.rs +++ b/tests/unsigned_int.rs @@ -22,7 +22,7 @@ impl From for config::ValueKind { fn from(unsigned: Unsigned) -> Self { let mut properties = indexmap::IndexMap::new(); properties.insert( - "unsigned".to_string(), + "unsigned".to_owned(), config::Value::from(unsigned.unsigned), );