rust-lang / rust-lang/rust-clippy
Clippy should detect opportunities for `into_` variants
Open
Nobody has claimed this yet.
A-lint
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
Identify places where an into_* function variant might be more efficient than cases where a non-into plus a clone is being used.
Lint Name
use_into_version
Category
style, perf
Advantage
- Removes unnecessary allocations of types by moving them
- Cleans up code
Drawbacks
No response
Example
// Note: this function receives and returns owned values
fn get_keys(hm: HashMap<String, u32>) -> Vec<String> {
hm.keys().map(|k| k.to_string()).collect()
}
Could be written as:
fn get_keys(hm: HashMap<String, u32>) -> Vec<String> {
hm.into_keys().collect()
}
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
Start by reviewing how Clippy lints are structured and how the proposed use_into_version pattern could be detected. Use the HashMap<String, u32> example as the initial case, then determine the intended broader scope. Done means the lint identifies eligible non-into calls followed by cloning and avoids inappropriate suggestions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100