]> git.lizzy.rs Git - rust.git/blob - tests/ui/iter_nth_zero.rs
Merge commit '984330a6ee3c4d15626685d6dc8b7b759ff630bd' into clippyup
[rust.git] / tests / ui / iter_nth_zero.rs
1 // run-rustfix
2
3 #![warn(clippy::iter_nth_zero)]
4 use std::collections::HashSet;
5
6 struct Foo;
7
8 impl Foo {
9     fn nth(&self, index: usize) -> usize {
10         index + 1
11     }
12 }
13
14 fn main() {
15     let f = Foo {};
16     f.nth(0); // lint does not apply here
17
18     let mut s = HashSet::new();
19     s.insert(1);
20     let _x = s.iter().nth(0);
21
22     let mut s2 = HashSet::new();
23     s2.insert(2);
24     let mut iter = s2.iter();
25     let _y = iter.nth(0);
26
27     let mut s3 = HashSet::new();
28     s3.insert(3);
29     let mut iter2 = s3.iter();
30     let _unwrapped = iter2.nth(0).unwrap();
31 }