rust-lang / rust-lang/rust-clippy
lint `vec.clone().into_iter().stuff().collect()` to suggest `vec.iter().stuff().cloned().collect()`
Open
Nobody has claimed this yet.
A-lint
L-complexity
L-perf
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Found the following code in the wild
let w: Vec<String> = vec_of_string
.clone()
.into_iter()
.filter(|s| s.len() < 10)
.collect();
Not sure what other things should be linted, but at least filter and filter_map after a clone+into_iter
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or entry point is named. Start from the Rust example and determine the intended lint coverage for clone followed by into_iter and filter or filter_map; done means the relevant cases are linted with the suggested iter and cloned form, with tests demonstrating the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100