diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 22e463f7a32..1cbc276e4a7 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -96,6 +96,7 @@ nix = { workspace = true, features = [ "poll", ] } xattr = { workspace = true, optional = true } +itertools = { workspace = true, optional = true } [dev-dependencies] tempfile = { workspace = true } @@ -186,4 +187,4 @@ wide = [] tty = [] time = ["jiff"] uptime = ["jiff", "libc", "windows-sys", "utmpx", "utmp-classic"] -benchmark = ["divan", "tempfile"] +benchmark = ["divan", "itertools", "tempfile"] diff --git a/src/uucore/src/lib/features/benchmark.rs b/src/uucore/src/lib/features/benchmark.rs index 8be0baf720a..29f2c1a59b7 100644 --- a/src/uucore/src/lib/features/benchmark.rs +++ b/src/uucore/src/lib/features/benchmark.rs @@ -12,6 +12,8 @@ use std::fs::File; use std::io::{BufWriter, Write}; use std::path::{Path, PathBuf}; +use itertools::Itertools as _; + /// Create a temporary file with test data pub fn create_test_file(data: &[u8], temp_dir: &Path) -> PathBuf { let file_path = temp_dir.join("test_data.txt"); @@ -32,8 +34,9 @@ where F: FnOnce(std::vec::IntoIter) -> i32, { // Prepend a dummy program name as argv[0] since clap expects it - let mut os_args: Vec = vec!["benchmark".into()]; - os_args.extend(args.iter().map(|s| (*s).into())); + let os_args = std::iter::once("benchmark".into()) + .chain(args.iter().map(Into::into)) + .collect_vec(); util_func(os_args.into_iter()) }