mirror of
https://github.com/nushell/nushell
synced 2024-12-29 14:33:13 +00:00
drop redundant iter -> vec -> iter
This commit is contained in:
parent
cc8a470668
commit
b3b51a2ed6
1 changed files with 3 additions and 8 deletions
|
@ -124,18 +124,13 @@ impl Command for Cp {
|
||||||
let sources = sources.paths_applying_with(|(source_file, depth_level)| {
|
let sources = sources.paths_applying_with(|(source_file, depth_level)| {
|
||||||
let mut dest = destination.clone();
|
let mut dest = destination.clone();
|
||||||
let path = canonicalize_with(&source_file, &path)?;
|
let path = canonicalize_with(&source_file, &path)?;
|
||||||
|
let components = path
|
||||||
let comps: Vec<_> = path
|
|
||||||
.components()
|
.components()
|
||||||
.map(|fragment| fragment.as_os_str())
|
.map(|fragment| fragment.as_os_str())
|
||||||
.rev()
|
.rev()
|
||||||
.take(1 + depth_level)
|
.take(1 + depth_level);
|
||||||
.collect();
|
|
||||||
|
|
||||||
for fragment in comps.into_iter().rev() {
|
|
||||||
dest.push(fragment);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
components.for_each(|fragment| dest.push(fragment));
|
||||||
Ok((PathBuf::from(&source_file), dest))
|
Ok((PathBuf::from(&source_file), dest))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue