]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/inspect_for_each.rs
Merge commit '61eb38aeda6cb54b93b872bf503d70084c4d621c' into clippyup
[rust.git] / src / tools / clippy / tests / ui / inspect_for_each.rs
1 #![warn(clippy::inspect_for_each)]
2
3 fn main() {
4     let a: Vec<usize> = vec![1, 2, 3, 4, 5];
5
6     let mut b: Vec<usize> = Vec::new();
7     a.into_iter().inspect(|x| assert!(*x > 0)).for_each(|x| {
8         let y = do_some(x);
9         let z = do_more(y);
10         b.push(z);
11     });
12
13     assert_eq!(b, vec![4, 5, 6, 7, 8]);
14 }
15
16 fn do_some(a: usize) -> usize {
17     a + 1
18 }
19
20 fn do_more(a: usize) -> usize {
21     a + 2
22 }