From 9ba9878f1adf05b099a7a4e5d9f835e92668d38f Mon Sep 17 00:00:00 2001 From: Denis Cornehl Date: Wed, 17 Apr 2024 16:33:58 +0200 Subject: [PATCH] upgrade toml dependency --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- src/lib.rs | 4 ---- src/prepare.rs | 19 ++++++++----------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cf7de4..01c4e30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - New method `LogStorage::set_max_line_length` to limit the logged line length when capturing builds logs +### Changed + +- updated `toml` dependency to 0.8. + ## [0.16.0] - 2023-05-02 ### Added diff --git a/Cargo.toml b/Cargo.toml index 3013461..8973297 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ flate2 = "1" tar = "0.4.0" percent-encoding = "2.1.0" walkdir = "2.2" -toml = "0.5" +toml = "0.8.12" fs2 = "0.4.3" remove_dir_all = "0.7" base64 = "0.13.0" diff --git a/src/lib.rs b/src/lib.rs index 0dde7ef..1de8dd4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,10 +20,6 @@ //! [crater]: https://github.com/rust-lang/crater //! [docsrs]: https://github.com/rust-lang/docs.rs -#[cfg(test)] -#[macro_use] -extern crate toml; - mod build; pub mod cmd; mod crates; diff --git a/src/prepare.rs b/src/prepare.rs index 402db27..3f589fe 100644 --- a/src/prepare.rs +++ b/src/prepare.rs @@ -355,7 +355,7 @@ impl<'a> TomlTweaker<'a> { pub fn save(self, output_file: &Path) -> Result<(), Error> { let crate_name = self.krate.to_string(); - ::std::fs::write(output_file, Value::Table(self.table).to_string().as_bytes())?; + ::std::fs::write(output_file, toml::to_string(&self.table)?.as_bytes())?; info!( "tweaked toml for {} written to {}", crate_name, @@ -393,7 +393,7 @@ mod tests { use super::TomlTweaker; use crate::build::{CratePatch, GitCratePatch, PathCratePatch}; use crate::crates::Crate; - use toml::{self, Value}; + use toml::toml; #[test] fn test_tweak_table_noop() { @@ -409,11 +409,10 @@ mod tests { let krate = Crate::local("/dev/null".as_ref()); let patches: Vec = Vec::new(); - let mut tweaker = - TomlTweaker::new_with_table(&krate, toml.as_table().unwrap().clone(), &patches); + let mut tweaker = TomlTweaker::new_with_table(&krate, toml, &patches); tweaker.tweak(); - assert_eq!(Value::Table(tweaker.table), result); + assert_eq!(tweaker.table, result); } #[test] @@ -445,11 +444,10 @@ mod tests { let krate = Crate::local("/dev/null".as_ref()); let patches: Vec = Vec::new(); - let mut tweaker = - TomlTweaker::new_with_table(&krate, toml.as_table().unwrap().clone(), &patches); + let mut tweaker = TomlTweaker::new_with_table(&krate, toml, &patches); tweaker.tweak(); - assert_eq!(Value::Table(tweaker.table), result); + assert_eq!(tweaker.table, result); } #[test] @@ -504,10 +502,9 @@ mod tests { path: "/path/to/baz".into(), }), ]; - let mut tweaker = - TomlTweaker::new_with_table(&krate, toml.as_table().unwrap().clone(), &patches); + let mut tweaker = TomlTweaker::new_with_table(&krate, toml, &patches); tweaker.tweak(); - assert_eq!(Value::Table(tweaker.table), result); + assert_eq!(tweaker.table, result); } }