diff options
Diffstat (limited to 'src/tools/clippy/src/docs/unnecessary_wraps.txt')
-rw-r--r-- | src/tools/clippy/src/docs/unnecessary_wraps.txt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/unnecessary_wraps.txt b/src/tools/clippy/src/docs/unnecessary_wraps.txt new file mode 100644 index 000000000..c0a23d492 --- /dev/null +++ b/src/tools/clippy/src/docs/unnecessary_wraps.txt @@ -0,0 +1,36 @@ +### What it does +Checks for private functions that only return `Ok` or `Some`. + +### Why is this bad? +It is not meaningful to wrap values when no `None` or `Err` is returned. + +### Known problems +There can be false positives if the function signature is designed to +fit some external requirement. + +### Example +``` +fn get_cool_number(a: bool, b: bool) -> Option<i32> { + if a && b { + return Some(50); + } + if a { + Some(0) + } else { + Some(10) + } +} +``` +Use instead: +``` +fn get_cool_number(a: bool, b: bool) -> i32 { + if a && b { + return 50; + } + if a { + 0 + } else { + 10 + } +} +```
\ No newline at end of file |