From 392344c93a5bbebc0bea7d5a79b778465ca18df6 Mon Sep 17 00:00:00 2001 From: David Campbell Date: Thu, 19 Sep 2024 19:45:57 -0400 Subject: [PATCH] Fix clippy::cloned_instead_of_copied. --- src/uu/hashsum/src/hashsum.rs | 2 +- src/uu/ptx/src/ptx.rs | 2 +- src/uu/tr/src/operation.rs | 4 ++-- src/uucore/src/lib/features/fs.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index f37f8445c..304938490 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -96,7 +96,7 @@ fn create_algorithm_from_flags(matches: &ArgMatches) -> UResult { set_or_err(detect_algo("b3sum", None)?)?; } if matches.get_flag("sha3") { - let bits = matches.get_one::("bits").cloned(); + let bits = matches.get_one::("bits").copied(); set_or_err(create_sha3(bits)?)?; } if matches.get_flag("sha3-224") { diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index 0fb711798..3316b20be 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -129,7 +129,7 @@ impl WordFilter { HashSet::new() // really only chars found in file } else { // GNU off means at least these are considered - [' ', '\t', '\n'].iter().cloned().collect() + [' ', '\t', '\n'].iter().copied().collect() }; hs.extend(chars); Some(hs) diff --git a/src/uu/tr/src/operation.rs b/src/uu/tr/src/operation.rs index e6eb08748..3eedb5ba9 100644 --- a/src/uu/tr/src/operation.rs +++ b/src/uu/tr/src/operation.rs @@ -112,7 +112,7 @@ impl Sequence { Self::Class(class) => match class { Class::Alnum => Box::new((b'0'..=b'9').chain(b'A'..=b'Z').chain(b'a'..=b'z')), Class::Alpha => Box::new((b'A'..=b'Z').chain(b'a'..=b'z')), - Class::Blank => Box::new(unicode_table::BLANK.iter().cloned()), + Class::Blank => Box::new(unicode_table::BLANK.iter().copied()), Class::Control => Box::new((0..=31).chain(std::iter::once(127))), Class::Digit => Box::new(b'0'..=b'9'), Class::Graph => Box::new( @@ -137,7 +137,7 @@ impl Sequence { .chain(123..=126), ), Class::Punct => Box::new((33..=47).chain(58..=64).chain(91..=96).chain(123..=126)), - Class::Space => Box::new(unicode_table::SPACES.iter().cloned()), + Class::Space => Box::new(unicode_table::SPACES.iter().copied()), Class::Xdigit => Box::new((b'0'..=b'9').chain(b'A'..=b'F').chain(b'a'..=b'f')), Class::Lower => Box::new(b'a'..=b'z'), Class::Upper => Box::new(b'A'..=b'Z'), diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index 73c61e0a3..e0c8ea79d 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -231,7 +231,7 @@ pub enum ResolveMode { /// replace this once that lands pub fn normalize_path(path: &Path) -> PathBuf { let mut components = path.components().peekable(); - let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().cloned() { + let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().copied() { components.next(); PathBuf::from(c.as_os_str()) } else {