From 1692dd0fe4ba244e4f290f1680f3ad73f0900b37 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Sat, 4 Jul 2020 14:14:57 -0700 Subject: [PATCH 1/3] Turn off all regex deps except unicode This removes dependencies on aho-corasick, memchr, thread_local, and lazy_static. version-sync is a build and test-time dependency that does not need to be super fast. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3772917..e9ffb8d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,4 +28,4 @@ proc-macro2 = { version = "1.0", features = ["span-locations"] } toml = "0.5" url = "2.0" itertools = "0.9" -regex = "1.1" +regex = { version = "1.1", default-features = false, features = ["std", "unicode"] } From 13f07ce3514400d389e1e798b5685eae3b3a50c5 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Sat, 4 Jul 2020 14:17:27 -0700 Subject: [PATCH 2/3] Implement join free function for joining iterators This commit re-implements itertools::join in the helpers module. The implementation is small -- less than 15 lines of code -- which does not seem to justify a dependency on an entire external crate. This enables removing the itertools dependency and transitively removes either. --- Cargo.toml | 1 - src/helpers.rs | 23 ++++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e9ffb8d..1986de4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,5 +27,4 @@ syn = { version = "1.0", features = ["full"] } proc-macro2 = { version = "1.0", features = ["span-locations"] } toml = "0.5" url = "2.0" -itertools = "0.9" regex = { version = "1.1", default-features = false, features = ["std", "unicode"] } diff --git a/src/helpers.rs b/src/helpers.rs index 991d8c0..48b7950 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,14 +1,35 @@ +use std::fmt::Display; use std::fs::File; use std::io::{self, Read}; use std::result; -use itertools::join; use semver_parser::range::{Op, VersionReq}; use semver_parser::version::Version; /// The common result type, our errors will be simple strings. pub type Result = result::Result; +fn join(iter: T, sep: &str) -> String +where + T: IntoIterator, + T::Item: Display, +{ + let mut buf = String::new(); + let mut iter = iter.into_iter(); + if let Some(item) = iter.next() { + let item = item.to_string(); + buf.push_str(&item); + } else { + return buf; + } + for item in iter { + buf.push_str(sep); + let item = item.to_string(); + buf.push_str(&item); + } + buf +} + /// Return all data from `path`. pub fn read_file(path: &str) -> io::Result { let mut file = File::open(path)?; From e5a7dc958d7ddacbe6f1460ac9b28bc980f39a22 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Sat, 4 Jul 2020 14:26:36 -0700 Subject: [PATCH 3/3] Bump regex to 1.3 regex 1.3 is the first to expose the feature flags we're disabling. https://github.com/rust-lang/regex/pull/613 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1986de4..5bb24fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,4 +27,4 @@ syn = { version = "1.0", features = ["full"] } proc-macro2 = { version = "1.0", features = ["span-locations"] } toml = "0.5" url = "2.0" -regex = { version = "1.1", default-features = false, features = ["std", "unicode"] } +regex = { version = "1.3", default-features = false, features = ["std", "unicode"] }