From 241091dd2c45ce63884501b91cb983faaf949386 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sat, 31 Jan 2026 12:16:31 +0000 Subject: [PATCH] clippy: fix map_clone lint --- Cargo.lock | 1 + Cargo.toml | 3 ++- src/bin/coreutils.rs | 6 ++---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c82b84cc5..c5c50b217 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -537,6 +537,7 @@ dependencies = [ "fluent-syntax", "glob", "hex-literal", + "itertools 0.14.0", "jiff", "libc", "nix", diff --git a/Cargo.toml b/Cargo.toml index 228272604..bfd06ded9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -419,10 +419,11 @@ uu_checksum_common = { version = "0.6.0", path = "src/uu/checksum_common" } uutests = { version = "0.6.0", package = "uutests", path = "tests/uutests" } [dependencies] -clap.workspace = true clap_complete = { workspace = true, optional = true } clap_mangen = { workspace = true, optional = true } +clap.workspace = true fluent-syntax = { workspace = true, optional = true } +itertools.workspace = true phf.workspace = true selinux = { workspace = true, optional = true } textwrap.workspace = true diff --git a/src/bin/coreutils.rs b/src/bin/coreutils.rs index 55c885237..8cd1f73cf 100644 --- a/src/bin/coreutils.rs +++ b/src/bin/coreutils.rs @@ -5,6 +5,7 @@ use clap::Command; use coreutils::validation; +use itertools::Itertools as _; use std::cmp; use std::ffi::OsString; use std::io::{self, Write}; @@ -28,10 +29,7 @@ fn usage(utils: &UtilityMap, name: &str) { println!("Options:"); println!(" --list lists all defined functions, one per row\n"); println!("Currently defined functions:\n"); - #[allow(clippy::map_clone)] - let mut utils: Vec<&str> = utils.keys().map(|&s| s).collect(); - utils.sort_unstable(); - let display_list = utils.join(", "); + let display_list = utils.keys().copied().sorted_unstable().join(", "); let width = cmp::min(textwrap::termwidth(), 100) - 4 * 2; // (opinion/heuristic) max 100 chars wide with 4 character side indentions println!( "{}",