]> git.lizzy.rs Git - rust.git/blob - tests/ui/copy_iterator.rs
Adapt the *.stderr files of the ui-tests to the tool_lints
[rust.git] / tests / ui / copy_iterator.rs
1 #![feature(tool_lints)]
2
3 #![warn(clippy::copy_iterator)]
4
5 #[derive(Copy, Clone)]
6 struct Countdown(u8);
7
8 impl Iterator for Countdown {
9     type Item = u8;
10
11     fn next(&mut self) -> Option<u8> {
12         self.0.checked_sub(1).map(|c| {
13             self.0 = c;
14             c
15         })
16     }
17 }
18
19 fn main() {
20     let my_iterator = Countdown(5);
21     let a: Vec<_> = my_iterator.take(1).collect();
22     assert_eq!(a.len(), 1);
23     let b: Vec<_> = my_iterator.collect();
24     assert_eq!(b.len(), 5);
25 }