Repository: toml-rs/toml (language: rust)

Issue:
Dropping itertools dependency
`toml_edit` has a dependency on `itertools` only for `join`, and it's only used in a few areas. Could this be vendored?


Discussion / hints:

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index 991a14c6..9996798f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -976,7 +976,6 @@ name = "toml_edit"
 version = "0.17.1"
 dependencies = [
  "indexmap",
- "itertools",
  "kstring",
  "libtest-mimic 0.6.0",
  "nom8",
diff --git a/crates/toml_edit/Cargo.toml b/crates/toml_edit/Cargo.toml
index 711da76f..4920597a 100644
--- a/crates/toml_edit/Cargo.toml
+++ b/crates/toml_edit/Cargo.toml
@@ -49,7 +49,6 @@ unbounded = []
 [dependencies]
 indexmap = "1.9.1"
 nom8 = "0.2.0"
-itertools = "0.10.5"
 serde = { version = "1.0.145", features = ["derive"], optional = true }
 kstring = { version = "2.0.0", features = ["max_inline"], optional = true }
 toml_datetime = { version = "0.5.1", path = "../toml_datetime" }
diff --git a/crates/toml_edit/src/de/mod.rs b/crates/toml_edit/src/de/mod.rs
index 7a7b80f8..108f692b 100644
--- a/crates/toml_edit/src/de/mod.rs
+++ b/crates/toml_edit/src/de/mod.rs
@@ -2,7 +2,6 @@
 //!
 //! This module contains all the Serde support for deserializing TOML documents into Rust structures.
 
-use itertools::Itertools;
 use serde::de::DeserializeOwned;
 
 mod array;
@@ -286,8 +285,12 @@ pub(crate) fn validate_struct_keys(
         Err(Error::custom(
             format!(
                 "unexpected keys in table: {}, available keys: {}",
-                extra_fields.iter().map(|k| k.key.get()).join(", "),
-                fields.iter().join(", "),
+                extra_fields
+                    .iter()
+                    .map(|k| k.key.get())
+                    .collect::<Vec<_>>()
+                    .join(", "),
+                fields.join(", "),
             ),
             extra_fields[0].key.span(),
         ))
diff --git a/crates/toml_edit/src/parser/errors.rs b/crates/toml_edit/src/parser/errors.rs
index c844b131..ffe30fea 100644
--- a/crates/toml_edit/src/parser/errors.rs
+++ b/crates/toml_edit/src/parser/errors.rs
@@ -1,8 +1,6 @@
 use std::error::Error as StdError;
 use std::fmt::{Display, Formatter, Result};
 
-use itertools::Itertools;
-
 use crate::parser::prelude::*;
 use crate::Key;
 
@@ -474,7 +472,7 @@ impl Display for CustomError {
                     if table.is_empty() {
                         write!(f, "duplicate key `{}` in document root", key)
                     } else {
-                        let path = table.iter().join(".");
+                        let path = table.iter().map(|k| k.get()).collect::<Vec<_>>().join(".");
                         write!(f, "duplicate key `{}` in table `{}`", key, path)
                     }
                 } else {
@@ -482,7 +480,7 @@ impl Display for CustomError {
                 }
             }
             CustomError::DottedKeyExtendWrongType { key, actual } => {
-                let path = key.iter().join(".");
+                let path = key.iter().map(|k| k.get()).collect::<Vec<_>>().join(".");
                 write!(
                     f,
                     "dotted key `{}` attempted to extend non-table type ({})",


Test patch: