2 #![warn(clippy::get_first)]
3 use std::collections::BTreeMap;
4 use std::collections::HashMap;
5 use std::collections::VecDeque;
12 fn get(&self, pos: usize) -> Option<&u32> {
18 let x = vec![2, 3, 5];
19 let _ = x.first(); // Use x.first()
24 let _ = y.first(); // Use y.first()
29 let _ = z.first(); // Use z.first()
33 let vecdeque: VecDeque<_> = x.iter().cloned().collect();
34 let hashmap: HashMap<u8, char> = HashMap::from_iter(vec![(0, 'a'), (1, 'b')]);
35 let btreemap: BTreeMap<u8, char> = BTreeMap::from_iter(vec![(0, 'a'), (1, 'b')]);
36 let _ = vecdeque.get(0); // Do not lint, because VecDeque is not slice.
37 let _ = hashmap.get(&0); // Do not lint, because HashMap is not slice.
38 let _ = btreemap.get(&0); // Do not lint, because BTreeMap is not slice.
40 let bar = Bar { arr: [0, 1, 2] };
41 let _ = bar.get(0); // Do not lint, because Bar is struct.