Suggest Vec::retain()
in cases of assigning a chain of .filter().collect()
to the original variable.
#8097
Labels
A-lint
Area: New lints
What it does
Guides users to use
Vec::retain()
over various permutations ofinto_iter().filter().collect()
if used to assign over the original vector.Lint Name
vec_retain
Category
style, complexity, perf, pedantic
Advantage
Conciseness, readability, and reuses existing memory (in the
.iter()...copied()
case)Drawbacks
Difficulty parsing out particularly complex chains of function calls.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: