2023-07-02 14:35:19 +02:00
|
|
|
#![allow(clippy::useless_vec)]
|
2019-12-18 18:59:43 +02:00
|
|
|
#[warn(clippy::range_zip_with_len)]
|
2015-08-15 12:55:25 -04:00
|
|
|
fn main() {
|
2018-12-09 23:26:16 +01:00
|
|
|
let v1 = vec![1, 2, 3];
|
|
|
|
let v2 = vec![4, 5];
|
2017-02-08 14:58:07 +01:00
|
|
|
let _x = v1.iter().zip(0..v1.len());
|
2023-08-24 21:32:12 +02:00
|
|
|
//~^ ERROR: it is more idiomatic to use `v1.iter().enumerate()`
|
|
|
|
//~| NOTE: `-D clippy::range-zip-with-len` implied by `-D warnings`
|
2015-12-12 21:35:35 -08:00
|
|
|
let _y = v1.iter().zip(0..v2.len()); // No error
|
2015-08-15 12:55:25 -04:00
|
|
|
}
|
2017-10-12 23:24:21 +09:00
|
|
|
|
|
|
|
#[allow(unused)]
|
|
|
|
fn no_panic_with_fake_range_types() {
|
|
|
|
struct Range {
|
|
|
|
foo: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
let _ = Range { foo: 0 };
|
|
|
|
}
|