Open oli-obk opened 5 years ago
I think this can be split into two parts:
.clone().into_iter()
, suggesting .iter().cloned()
instead (to skip the container allocation).cloned().filter()
, suggesting .filter().cloned()
instead (to skip filtered-out things)Throwing a wild idea into the mix: sort adaptors by their individual performance impact and then find a global optimum of the combination. I believe this will allow for a more generic lint. As for an implementation, a guided brute-force should do if the adaptor chain is short, say, < 10-15 elements; if not, it's too long anyway (is there a lint for that already?).
I feel like that would be way too hard to implement and seems to have caused this idea to get lost for a couple years. A lint for .clone().into_iter()
seems like quite an easy thing to implement.
Found the following code in the wild
Not sure what other things should be linted, but at least filter and filter_map after a clone+into_iter