]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/iter_nth_zero.rs
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / iter_nth_zero.rs
CommitLineData
f20569fa
XL
1// run-rustfix
2
3#![warn(clippy::iter_nth_zero)]
4use std::collections::HashSet;
5
6struct Foo {}
7
8impl Foo {
9 fn nth(&self, index: usize) -> usize {
10 index + 1
11 }
12}
13
14fn 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}