diff options
Diffstat (limited to 'src/tools/clippy/src/docs/field_reassign_with_default.txt')
-rw-r--r-- | src/tools/clippy/src/docs/field_reassign_with_default.txt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/field_reassign_with_default.txt b/src/tools/clippy/src/docs/field_reassign_with_default.txt new file mode 100644 index 000000000..e58b7239f --- /dev/null +++ b/src/tools/clippy/src/docs/field_reassign_with_default.txt @@ -0,0 +1,23 @@ +### What it does +Checks for immediate reassignment of fields initialized +with Default::default(). + +### Why is this bad? +It's more idiomatic to use the [functional update syntax](https://doc.rust-lang.org/reference/expressions/struct-expr.html#functional-update-syntax). + +### Known problems +Assignments to patterns that are of tuple type are not linted. + +### Example +``` +let mut a: A = Default::default(); +a.i = 42; +``` + +Use instead: +``` +let a = A { + i: 42, + .. Default::default() +}; +```
\ No newline at end of file |