diff options
| author | TennyZhuang <zty0826@gmail.com> | 2022-10-16 16:02:23 +0800 |
|---|---|---|
| committer | TennyZhuang <zty0826@gmail.com> | 2022-10-16 16:03:50 +0800 |
| commit | 7ac97b69fc81fcd5cbd2a7c862187f6a6c6ea354 (patch) | |
| tree | cbb596de635702a984233c4ede7e2aba31a2fc6e /src/docs | |
| parent | ff33d6e712ebf1068e8d6109e56f2f5d1e82054c (diff) | |
Add new lint `partial_pub_fields`
Signed-off-by: TennyZhuang <zty0826@gmail.com>
Diffstat (limited to 'src/docs')
| -rw-r--r-- | src/docs/partial_pub_fields.txt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/docs/partial_pub_fields.txt b/src/docs/partial_pub_fields.txt new file mode 100644 index 00000000000..a332ec8c28a --- /dev/null +++ b/src/docs/partial_pub_fields.txt @@ -0,0 +1,27 @@ +### What it does +Checks whether partial fields of a struct are public. + +Either make all fields of a type public, or make none of them public + +### Why is this bad? +Most types should either be: +* Abstract data types: complex objects with opaque implementation which guard +interior invariants and expose intentionally limited API to the outside world. +* Data: relatively simple objects which group a bunch of related attributes together. + +### Example +``` +pub struct Color { + pub r, + pub g, + b, +} +``` +Use instead: +``` +pub struct Color { + pub r, + pub g, + pub b, +} +``` \ No newline at end of file |
