From 27b26188c4ba8d347ca68fd2afa5ff43258cba4f Mon Sep 17 00:00:00 2001 From: Jeb Rosen Date: Sun, 19 Jan 2020 10:57:48 -0800 Subject: [PATCH] Update 'toml' to '0.5'. --- contrib/lib/src/databases.rs | 3 +-- contrib/lib/tests/databases.rs | 11 +++++------ core/lib/Cargo.toml | 2 +- core/lib/src/config/mod.rs | 2 +- core/lib/src/config/toml_ext.rs | 13 +++++++------ 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/contrib/lib/src/databases.rs b/contrib/lib/src/databases.rs index 16dae8ba..f5ca7e1c 100644 --- a/contrib/lib/src/databases.rs +++ b/contrib/lib/src/databases.rs @@ -388,7 +388,6 @@ pub use tokio::task::spawn_blocking; feature = "diesel_mysql_pool"))] pub extern crate diesel; -use std::collections::BTreeMap; use std::fmt::{self, Display, Formatter}; use std::marker::{Send, Sized}; @@ -444,7 +443,7 @@ pub struct DatabaseConfig<'a> { pub pool_size: u32, /// Any extra options that are included in the configuration, **excluding** /// the url and pool_size. - pub extras: BTreeMap, + pub extras: rocket::config::Map, } /// A wrapper around `r2d2::Error`s or a custom database error type. diff --git a/contrib/lib/tests/databases.rs b/contrib/lib/tests/databases.rs index 62d4df3b..47ead732 100644 --- a/contrib/lib/tests/databases.rs +++ b/contrib/lib/tests/databases.rs @@ -12,8 +12,7 @@ mod databases_tests { #[cfg(all(feature = "databases", feature = "sqlite_pool"))] #[cfg(test)] mod rusqlite_integration_test { - use std::collections::BTreeMap; - use rocket::config::{Config, Environment, Value}; + use rocket::config::{Config, Environment, Value, Map}; use rocket_contrib::databases::rusqlite; use rocket_contrib::database; @@ -24,8 +23,8 @@ mod rusqlite_integration_test { #[rocket::async_test] async fn deref_mut_impl_present() { - let mut test_db: BTreeMap = BTreeMap::new(); - let mut test_db_opts: BTreeMap = BTreeMap::new(); + let mut test_db: Map = Map::new(); + let mut test_db_opts: Map = Map::new(); test_db_opts.insert("url".into(), Value::String(":memory:".into())); test_db.insert("test_db".into(), Value::Table(test_db_opts)); let config = Config::build(Environment::Development) @@ -45,8 +44,8 @@ mod rusqlite_integration_test { #[rocket::async_test] async fn deref_impl_present() { - let mut test_db: BTreeMap = BTreeMap::new(); - let mut test_db_opts: BTreeMap = BTreeMap::new(); + let mut test_db: Map = Map::new(); + let mut test_db_opts: Map = Map::new(); test_db_opts.insert("url".into(), Value::String(":memory:".into())); test_db.insert("test_db".into(), Value::Table(test_db_opts)); let config = Config::build(Environment::Development) diff --git a/core/lib/Cargo.toml b/core/lib/Cargo.toml index 5f24b429..4777d3f9 100644 --- a/core/lib/Cargo.toml +++ b/core/lib/Cargo.toml @@ -29,7 +29,7 @@ rocket_http = { version = "0.5.0-dev", path = "../http" } futures = "0.3.0" yansi = "0.5" log = { version = "0.4", features = ["std"] } -toml = "0.4.7" +toml = "0.5" num_cpus = "1.0" state = "0.4.1" time = "0.2.11" diff --git a/core/lib/src/config/mod.rs b/core/lib/src/config/mod.rs index 3703ec0c..c08dae5b 100644 --- a/core/lib/src/config/mod.rs +++ b/core/lib/src/config/mod.rs @@ -199,7 +199,7 @@ use std::path::{Path, PathBuf}; use toml; pub use self::custom_values::Limits; -pub use toml::value::{Array, Table, Value, Datetime}; +pub use toml::value::{Array, Map, Table, Value, Datetime}; pub use self::error::ConfigError; pub use self::environment::Environment; pub use self::config::Config; diff --git a/core/lib/src/config/toml_ext.rs b/core/lib/src/config/toml_ext.rs index c0ec75e1..0e5267d4 100644 --- a/core/lib/src/config/toml_ext.rs +++ b/core/lib/src/config/toml_ext.rs @@ -103,7 +103,8 @@ impl fmt::Display for LoggedValue<'_> { #[cfg(test)] mod test { - use std::collections::BTreeMap; + use toml::map::Map; + use super::parse_simple_toml_value; use super::Value::{self, *}; @@ -131,16 +132,16 @@ mod test { assert_parse!("[1, 2, 3]", vec![1, 2, 3].into()); assert_parse!("[1.32, 2]", Array(vec![1.32.into(), 2.into()])); - assert_parse!("{}", Table(BTreeMap::new())); + assert_parse!("{}", Table(Map::new())); assert_parse!("{a=b}", Table({ - let mut map = BTreeMap::new(); + let mut map = Map::new(); map.insert("a".into(), "b".into()); map })); assert_parse!("{v=1, on=true,pi=3.14}", Table({ - let mut map = BTreeMap::new(); + let mut map = Map::new(); map.insert("v".into(), 1.into()); map.insert("on".into(), true.into()); map.insert("pi".into(), 3.14.into()); @@ -148,7 +149,7 @@ mod test { })); assert_parse!("{v=[1, 2, 3], v2=[a, \"b\"], on=true,pi=3.14}", Table({ - let mut map = BTreeMap::new(); + let mut map = Map::new(); map.insert("v".into(), vec![1, 2, 3].into()); map.insert("v2".into(), vec!["a", "b"].into()); map.insert("on".into(), true.into()); @@ -157,7 +158,7 @@ mod test { })); assert_parse!("{v=[[1], [2, 3], [4,5]]}", Table({ - let mut map = BTreeMap::new(); + let mut map = Map::new(); let first: Value = vec![1].into(); let second: Value = vec![2, 3].into(); let third: Value = vec![4, 5].into();