]> git.lizzy.rs Git - rust.git/blob - src/docs/field_reassign_with_default.txt
new uninlined_format_args lint to inline explicit arguments
[rust.git] / src / docs / field_reassign_with_default.txt
1 ### What it does
2 Checks for immediate reassignment of fields initialized
3 with Default::default().
4
5 ### Why is this bad?
6 It's more idiomatic to use the [functional update syntax](https://doc.rust-lang.org/reference/expressions/struct-expr.html#functional-update-syntax).
7
8 ### Known problems
9 Assignments to patterns that are of tuple type are not linted.
10
11 ### Example
12 ```
13 let mut a: A = Default::default();
14 a.i = 42;
15 ```
16
17 Use instead:
18 ```
19 let a = A {
20     i: 42,
21     .. Default::default()
22 };
23 ```