From f78586ff7bbe37e2a396e6b97ae6a6a2820c1087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gonz=C3=A1lez?= Date: Sat, 15 Apr 2023 15:58:08 +0200 Subject: [PATCH 1/2] Remove now unused `itertools` dependency The `itertools` dependency became unused at a3b104a2edd7e7a7d2944d8ee06eacc77dc6da8c, so there is no point in declaring it as a dependency any longer. This was detected with the help of the [`cargo-udeps`](https://github.com/est31/cargo-udeps) tool. I then verified that it was not a false positive. --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3b0ce3fd..9fba627c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ path = "src/main.rs" required-features = ["binary"] [dependencies] -itertools = "0.10.3" zopfli = { version = "0.7.1", optional = true } rgb = "0.8.33" indexmap = "1.9.1" From 0ff1049eb7f387e0040c7b32c59c03bbf0021e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gonz=C3=A1lez?= Date: Sat, 15 Apr 2023 15:22:20 +0200 Subject: [PATCH 2/2] Gate dependency on `crossbeam-channel` behind the `parallel` feature `crossbeam-channel` is only used if the `parallel` flag is enabled, so it can be gated behind that feature flag to potentially reduce the size of the build dependency tree for dependent projects. While at it, I've fixed several warnings emmitted in tests/flags.rs. --- Cargo.toml | 7 +++++-- tests/flags.rs | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9fba627c..8f4a214d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,10 +29,13 @@ indexmap = "1.9.1" libdeflater = "0.11.0" log = "0.4.17" stderrlog = { version = "0.5.3", optional = true, default-features = false } -crossbeam-channel = "0.5.6" bitvec = "1.0.1" rustc-hash = "1.1.0" +[dependencies.crossbeam-channel] +optional = true +version = "0.5.6" + [dependencies.filetime] optional = true version = "0.2.17" @@ -60,7 +63,7 @@ rustc_version = "0.4.0" [features] binary = ["clap", "wild", "stderrlog"] default = ["binary", "filetime", "parallel", "zopfli"] -parallel = ["rayon", "indexmap/rayon"] +parallel = ["rayon", "indexmap/rayon", "crossbeam-channel"] freestanding = ["libdeflater/freestanding"] [lib] diff --git a/tests/flags.rs b/tests/flags.rs index 6ff0ee85..38db85b7 100644 --- a/tests/flags.rs +++ b/tests/flags.rs @@ -4,6 +4,7 @@ use oxipng::{InFile, OutFile}; #[cfg(feature = "filetime")] use std::cell::RefCell; use std::fs::remove_file; +#[cfg(feature = "zopfli")] use std::num::NonZeroU8; #[cfg(feature = "filetime")] use std::ops::Deref; @@ -95,9 +96,12 @@ fn test_it_converts( #[test] fn verbose_mode() { + #[cfg(feature = "parallel")] use crossbeam_channel::{unbounded, Sender}; use log::{set_logger, set_max_level, Level, LevelFilter, Log, Metadata, Record}; use std::cell::RefCell; + #[cfg(not(feature = "parallel"))] + use std::sync::mpsc::{channel as unbounded, Sender}; // Rust runs tests in parallel by default. // We want to make sure that we verify only logs from our test. @@ -169,7 +173,7 @@ fn verbose_mode() { thread_exec(); }); - let mut logs: Vec<_> = receiver.into_iter().collect(); + let logs: Vec<_> = receiver.into_iter().collect(); println!("logs={:?}", logs); assert_eq!(logs.len(), 9); let expected_logs = [