RS.CLIPPY.ITER_NOT_RETURNING_ITERATOR
Methods named `iter` or `iter_mut` that do not return an `Iterator`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: iter_not_returning_iterator. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Detects methods named iter or iter_mut that do not have a return type that implements Iterator.
Why is this bad?
Methods named iter or iter_mut conventionally return an Iterator.
Example
// `String` does not implement `Iterator`
struct Data {}
impl Data {
fn iter(&self) -> String {
todo!()
}
}
Use instead:
use std::str::Chars;
struct Data {}
impl Data {
fn iter(&self) -> Chars<\'static> {
todo!()
}
}