-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
E-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.L-perfLint: Belongs in the perf lint groupLint: Belongs in the perf lint group
Description
pub fn main() {
// we start with an iterator
let iter = vec![1, 2, 3].into_iter();
// we do something with the items and collect into a vec
let 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 :)
Metadata
Metadata
Assignees
Labels
E-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.L-perfLint: Belongs in the perf lint groupLint: Belongs in the perf lint group