rust/tests/ui/iter_next_slice.rs

26 lines
564 B
Rust
Raw Normal View History

//@run-rustfix
#![warn(clippy::iter_next_slice)]
2023-06-06 15:56:57 -05:00
#![allow(clippy::useless_vec)]
fn main() {
// test code goes here
let s = [1, 2, 3];
let v = vec![1, 2, 3];
let _ = s.iter().next();
2022-05-24 04:55:39 -05:00
// Should be replaced by s.first()
let _ = s[2..].iter().next();
// Should be replaced by s.get(2)
let _ = v[5..].iter().next();
// Should be replaced by v.get(5)
let _ = v.iter().next();
2022-05-24 04:55:39 -05:00
// Should be replaced by v.first()
let o = Some(5);
o.iter().next();
// Shouldn't be linted since this is not a Slice or an Array
}