]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/src/docs/unit_return_expecting_ord.txt
New upstream version 1.66.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / unit_return_expecting_ord.txt
CommitLineData
f2b60f7d
FG
1### What it does
2Checks for functions that expect closures of type
3Fn(...) -> Ord where the implemented closure returns the unit type.
4The lint also suggests to remove the semi-colon at the end of the statement if present.
5
6### Why is this bad?
7Likely, returning the unit type is unintentional, and
8could simply be caused by an extra semi-colon. Since () implements Ord
9it doesn't cause a compilation error.
10This is the same reasoning behind the unit_cmp lint.
11
12### Known problems
13If returning unit is intentional, then there is no
14way of specifying this without triggering needless_return lint
15
16### Example
17```
18let mut twins = vec!((1, 1), (2, 2));
19twins.sort_by_key(|x| { x.1; });
20```