summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/iter_not_returning_iterator.txt
blob: 0ca862910a6f072a8199956be2a29db0ecfdc13d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
### 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!()
   }
}
```