diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/clippy/src/docs/assign_op_pattern.txt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/assign_op_pattern.txt b/src/tools/clippy/src/docs/assign_op_pattern.txt new file mode 100644 index 000000000..f355c0cc1 --- /dev/null +++ b/src/tools/clippy/src/docs/assign_op_pattern.txt @@ -0,0 +1,28 @@ +### What it does +Checks for `a = a op b` or `a = b commutative_op a` +patterns. + +### Why is this bad? +These can be written as the shorter `a op= b`. + +### Known problems +While forbidden by the spec, `OpAssign` traits may have +implementations that differ from the regular `Op` impl. + +### Example +``` +let mut a = 5; +let b = 0; +// ... + +a = a + b; +``` + +Use instead: +``` +let mut a = 5; +let b = 0; +// ... + +a += b; +```
\ No newline at end of file |