2023-04-23 11:03:09 +00:00
|
|
|
//@run-rustfix
|
2020-06-09 14:36:01 +00:00
|
|
|
#![warn(clippy::iter_next_slice)]
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// test code goes here
|
|
|
|
let s = [1, 2, 3];
|
|
|
|
let v = vec![1, 2, 3];
|
|
|
|
|
2022-03-26 14:37:48 +00:00
|
|
|
let _ = s.iter().next();
|
2022-06-04 11:34:07 +00:00
|
|
|
// Should be replaced by s.first()
|
2020-06-09 14:36:01 +00:00
|
|
|
|
2022-03-26 14:37:48 +00:00
|
|
|
let _ = s[2..].iter().next();
|
2020-06-09 14:36:01 +00:00
|
|
|
// Should be replaced by s.get(2)
|
|
|
|
|
2022-03-26 14:37:48 +00:00
|
|
|
let _ = v[5..].iter().next();
|
2020-06-09 14:36:01 +00:00
|
|
|
// Should be replaced by v.get(5)
|
|
|
|
|
2022-03-26 14:37:48 +00:00
|
|
|
let _ = v.iter().next();
|
2022-06-04 11:34:07 +00:00
|
|
|
// Should be replaced by v.first()
|
2020-06-09 14:36:01 +00:00
|
|
|
|
|
|
|
let o = Some(5);
|
|
|
|
o.iter().next();
|
|
|
|
// Shouldn't be linted since this is not a Slice or an Array
|
|
|
|
}
|