]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/unnecessary_wraps.txt
:arrow_up: rust-analyzer
[rust.git] / src / tools / clippy / src / docs / unnecessary_wraps.txt
1 ### What it does
2 Checks for private functions that only return `Ok` or `Some`.
3
4 ### Why is this bad?
5 It is not meaningful to wrap values when no `None` or `Err` is returned.
6
7 ### Known problems
8 There can be false positives if the function signature is designed to
9 fit some external requirement.
10
11 ### Example
12 ```
13 fn get_cool_number(a: bool, b: bool) -> Option<i32> {
14     if a && b {
15         return Some(50);
16     }
17     if a {
18         Some(0)
19     } else {
20         Some(10)
21     }
22 }
23 ```
24 Use instead:
25 ```
26 fn get_cool_number(a: bool, b: bool) -> i32 {
27     if a && b {
28         return 50;
29     }
30     if a {
31         0
32     } else {
33         10
34     }
35 }
36 ```