]> git.lizzy.rs Git - rust.git/blob - src/docs/redundant_field_names.txt
35f20a466b3785dfcb7a5126e727d0de110f0d19
[rust.git] / src / docs / redundant_field_names.txt
1 ### What it does
2 Checks for fields in struct literals where shorthands
3 could be used.
4
5 ### Why is this bad?
6 If the field and variable names are the same,
7 the field name is redundant.
8
9 ### Example
10 ```
11 let bar: u8 = 123;
12
13 struct Foo {
14     bar: u8,
15 }
16
17 let foo = Foo { bar: bar };
18 ```
19 the last line can be simplified to
20 ```
21 let foo = Foo { bar };
22 ```