diff options
Diffstat (limited to 'src/tools/clippy/src/docs/cast_abs_to_unsigned.txt')
-rw-r--r-- | src/tools/clippy/src/docs/cast_abs_to_unsigned.txt | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/cast_abs_to_unsigned.txt b/src/tools/clippy/src/docs/cast_abs_to_unsigned.txt new file mode 100644 index 000000000..c5d8ee034 --- /dev/null +++ b/src/tools/clippy/src/docs/cast_abs_to_unsigned.txt @@ -0,0 +1,16 @@ +### What it does +Checks for uses of the `abs()` method that cast the result to unsigned. + +### Why is this bad? +The `unsigned_abs()` method avoids panic when called on the MIN value. + +### Example +``` +let x: i32 = -42; +let y: u32 = x.abs() as u32; +``` +Use instead: +``` +let x: i32 = -42; +let y: u32 = x.unsigned_abs(); +```
\ No newline at end of file |