about summary refs log tree commit diff
path: root/src/docs/partial_pub_fields.txt
blob: b529adf1547de3fb465c03a63cda7640301c36a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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: u8,
    pub g: u8,
    b: u8,
}
```
Use instead:
```
pub struct Color {
    pub r: u8,
    pub g: u8,
    pub b: u8,
}
```