rust-clippy/tests/ui/iter_next_loop.rs

17 lines
378 B
Rust
Raw Normal View History

2023-02-27 17:47:48 +00:00
#![allow(dead_code, unused, for_loops_over_fallibles)]
#![warn(clippy::iter_next_loop)]
fn main() {
let x = [1, 2, 3, 4];
2024-07-10 15:18:05 +00:00
for _ in x.iter().next() {}
2023-02-27 17:47:48 +00:00
struct Unrelated(&'static [u8]);
impl Unrelated {
fn next(&self) -> std::slice::Iter<u8> {
self.0.iter()
}
}
let u = Unrelated(&[0]);
for _v in u.next() {} // no error
}