Skip to content

Commit 4e8fc93

Browse files
missing_iterator_fold: test the lint
1 parent 96d30a0 commit 4e8fc93

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

Diff for: tests/ui/missing_iterator_fold.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#![warn(clippy::missing_iterator_fold)]
22

3-
fn main() {
4-
// test code goes here
3+
struct Countdown(u8);
4+
5+
impl Iterator for Countdown {
6+
type Item = u8;
7+
8+
fn next(&mut self) -> Option<u8> {
9+
self.0 = self.0.checked_sub(1)?;
10+
Some(self.0)
11+
}
512
}

Diff for: tests/ui/missing_iterator_fold.stderr

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error: you are implementing `Iterator` without specializing its `fold` method
2+
--> $DIR/missing_iterator_fold.rs:5:1
3+
|
4+
LL | / impl Iterator for Countdown {
5+
LL | | type Item = u8;
6+
LL | |
7+
LL | | fn next(&mut self) -> Option<u8> {
8+
... |
9+
LL | | }
10+
LL | | }
11+
| |_^
12+
|
13+
= note: `-D clippy::missing-iterator-fold` implied by `-D warnings`
14+
= help: to override `-D warnings` add `#[allow(clippy::missing_iterator_fold)]`
15+
16+
error: aborting due to 1 previous error
17+

0 commit comments

Comments
 (0)