1 #![feature(tool_lints)]
3 use std::collections::{HashMap, HashSet, BTreeSet};
5 #[warn(clippy::needless_collect)]
6 #[allow(unused_variables, clippy::iter_cloned_collect)]
9 let len = sample.iter().collect::<Vec<_>>().len();
10 if sample.iter().collect::<Vec<_>>().is_empty() {
13 sample.iter().cloned().collect::<Vec<_>>().contains(&1);
14 sample.iter().map(|x| (x, x)).collect::<HashMap<_, _>>().len();
15 // Notice the `HashSet`--this should not be linted
16 sample.iter().collect::<HashSet<_>>().len();
17 // Neither should this
18 sample.iter().collect::<BTreeSet<_>>().len();