]> git.lizzy.rs Git - rust.git/blob - src/docs/init_numbered_fields.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / init_numbered_fields.txt
1 ### What it does
2 Checks for tuple structs initialized with field syntax.
3 It will however not lint if a base initializer is present.
4 The lint will also ignore code in macros.
5
6 ### Why is this bad?
7 This may be confusing to the uninitiated and adds no
8 benefit as opposed to tuple initializers
9
10 ### Example
11 ```
12 struct TupleStruct(u8, u16);
13
14 let _ = TupleStruct {
15     0: 1,
16     1: 23,
17 };
18
19 // should be written as
20 let base = TupleStruct(1, 23);
21
22 // This is OK however
23 let _ = TupleStruct { 0: 42, ..base };
24 ```