]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/src/docs/redundant_closure.txt
New upstream version 1.66.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / redundant_closure.txt
CommitLineData
f2b60f7d
FG
1### What it does
2Checks for closures which just call another function where
3the function can be called directly. `unsafe` functions or calls where types
4get adjusted are ignored.
5
6### Why is this bad?
7Needlessly creating a closure adds code for no benefit
8and gives the optimizer more work.
9
10### Known problems
11If creating the closure inside the closure has a side-
12effect then moving the closure creation out will change when that side-
13effect runs.
14See [#1439](https://github.com/rust-lang/rust-clippy/issues/1439) for more details.
15
16### Example
17```
18xs.map(|x| foo(x))
19```
20
21Use instead:
22```
23// where `foo(_)` is a plain function that takes the exact argument type of `x`.
24xs.map(foo)
25```