diff options
| author | Philipp Krones <hello@philkrones.com> | 2022-11-21 19:59:07 +0100 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2022-11-21 20:01:17 +0100 |
| commit | fd5b85c957d92a3bc5fc754407d1e56aa9178d27 (patch) | |
| tree | cba25a7cb16b8f5981eb75b1138ece61bb412fb6 /src/docs/inconsistent_struct_constructor.txt | |
| parent | 80a4699aaeb17903cd55c3159764febf3ff4e7e9 (diff) | |
| parent | 51ec465cc3dfb62a2dad7e808b399fa76a1c9170 (diff) | |
Merge remote-tracking branch 'upstream/master' into rustup
Diffstat (limited to 'src/docs/inconsistent_struct_constructor.txt')
| -rw-r--r-- | src/docs/inconsistent_struct_constructor.txt | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/docs/inconsistent_struct_constructor.txt b/src/docs/inconsistent_struct_constructor.txt deleted file mode 100644 index eb682109a54..00000000000 --- a/src/docs/inconsistent_struct_constructor.txt +++ /dev/null @@ -1,40 +0,0 @@ -### What it does -Checks for struct constructors where all fields are shorthand and -the order of the field init shorthand in the constructor is inconsistent -with the order in the struct definition. - -### Why is this bad? -Since the order of fields in a constructor doesn't affect the -resulted instance as the below example indicates, - -``` -#[derive(Debug, PartialEq, Eq)] -struct Foo { - x: i32, - y: i32, -} -let x = 1; -let y = 2; - -// This assertion never fails: -assert_eq!(Foo { x, y }, Foo { y, x }); -``` - -inconsistent order can be confusing and decreases readability and consistency. - -### Example -``` -struct Foo { - x: i32, - y: i32, -} -let x = 1; -let y = 2; - -Foo { y, x }; -``` - -Use instead: -``` -Foo { x, y }; -``` \ No newline at end of file |
