Closed
Description
In this example:
use std::ops::Index;
struct S(Vec<u32>);
impl Index<usize> for S {
type Output = u32;
fn index(&self, index: usize) -> &u32 {
&self.0[index]
}
}
fn main() {
let s = S(vec![1, 2, 3]);
for i in 0..3 {
println!("{:?}", s[i]);
}
}
Clippy says "Consider using for item in s.iter().take(3)
, but s
does not have iter
method.