fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1//@aux-build:option_helpers.rs 2 3#![warn(clippy::iter_skip_next)] 4#![allow(clippy::disallowed_names)] 5#![allow(clippy::iter_nth)] 6#![allow(clippy::useless_vec)] 7#![allow(clippy::iter_out_of_bounds)] 8#![allow(unused_mut, dead_code)] 9 10extern crate option_helpers; 11 12use option_helpers::IteratorFalsePositives; 13 14/// Checks implementation of `ITER_SKIP_NEXT` lint 15fn main() { 16 let some_vec = vec![0, 1, 2, 3]; 17 let _ = some_vec.iter().nth(42); 18 let _ = some_vec.iter().cycle().nth(42); 19 let _ = (1..10).nth(10); 20 let _ = &some_vec[..].iter().nth(3); 21 let foo = IteratorFalsePositives { foo: 0 }; 22 let _ = foo.skip(42).next(); 23 let _ = foo.filter().skip(42).next(); 24 25 // fix #8128 26 let test_string = "1|1 2"; 27 let mut sp = test_string.split('|').map(|s| s.trim()); 28 let _: Vec<&str> = sp.nth(1).unwrap().split(' ').collect(); 29 if let Some(mut s) = Some(test_string.split('|').map(|s| s.trim())) { 30 let _: Vec<&str> = s.nth(1).unwrap().split(' ').collect(); 31 }; 32 fn check<T>(mut s: T) 33 where 34 T: Iterator<Item = String>, 35 { 36 let _: Vec<&str> = s.nth(1).unwrap().split(' ').collect(); 37 } 38}