]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/inspect_for_each.txt
Auto merge of #98559 - jackh726:remove-reempty, r=oli-obk
[rust.git] / src / tools / clippy / src / docs / inspect_for_each.txt
1 ### What it does
2 Checks for usage of `inspect().for_each()`.
3
4 ### Why is this bad?
5 It is the same as performing the computation
6 inside `inspect` at the beginning of the closure in `for_each`.
7
8 ### Example
9 ```
10 [1,2,3,4,5].iter()
11 .inspect(|&x| println!("inspect the number: {}", x))
12 .for_each(|&x| {
13     assert!(x >= 0);
14 });
15 ```
16 Can be written as
17 ```
18 [1,2,3,4,5].iter()
19 .for_each(|&x| {
20     println!("inspect the number: {}", x);
21     assert!(x >= 0);
22 });
23 ```