You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pubfnmain(){// we start with an iteratorlet iter = vec![1,2,3].into_iter();// we do something with the items and collect into a veclet v:Vec<i32> = iter.map(|x| x + 2).collect();// but the first and only use of the vec uses .iter() or .into_iter(), which means we could skip collecting entirely.
v.into_iter().for_each(|x| println!("{}", x));}
Would be awesome if clippy could catch such patterns :)
The text was updated successfully, but these errors were encountered:
needless_collect: catch x: Vec<_> = iter.collect(); x.into_iter() ...
changelog: Expand the needless_collect lint as suggested in rust-lang#5627 (WIP).
This PR is WIP because I can't figure out how to make the multi-part suggestion include its changes in the source code (the fixed is identical to the source, despite the lint making suggestions). Aside from that one issue, I think this should be good.
flip1995
added a commit
to flip1995/rust-clippy
that referenced
this issue
Aug 4, 2020
needless_collect: catch x: Vec<_> = iter.collect(); x.into_iter() ...
changelog: Expand the needless_collect lint as suggested in rust-lang#5627 (WIP).
This PR is WIP because I can't figure out how to make the multi-part suggestion include its changes in the source code (the fixed is identical to the source, despite the lint making suggestions). Aside from that one issue, I think this should be good.
Would be awesome if clippy could catch such patterns :)
The text was updated successfully, but these errors were encountered: