diff options
Diffstat (limited to 'src/docs/unneeded_field_pattern.txt')
| -rw-r--r-- | src/docs/unneeded_field_pattern.txt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/docs/unneeded_field_pattern.txt b/src/docs/unneeded_field_pattern.txt new file mode 100644 index 00000000000..3cd00a0f3e3 --- /dev/null +++ b/src/docs/unneeded_field_pattern.txt @@ -0,0 +1,26 @@ +### What it does +Checks for structure field patterns bound to wildcards. + +### Why is this bad? +Using `..` instead is shorter and leaves the focus on +the fields that are actually bound. + +### Example +``` +let f = Foo { a: 0, b: 0, c: 0 }; + +match f { + Foo { a: _, b: 0, .. } => {}, + Foo { a: _, b: _, c: _ } => {}, +} +``` + +Use instead: +``` +let f = Foo { a: 0, b: 0, c: 0 }; + +match f { + Foo { b: 0, .. } => {}, + Foo { .. } => {}, +} +``` \ No newline at end of file |
