diff options
Diffstat (limited to 'src/tools/clippy/src/docs/struct_excessive_bools.txt')
-rw-r--r-- | src/tools/clippy/src/docs/struct_excessive_bools.txt | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/struct_excessive_bools.txt b/src/tools/clippy/src/docs/struct_excessive_bools.txt new file mode 100644 index 000000000..9e197c786 --- /dev/null +++ b/src/tools/clippy/src/docs/struct_excessive_bools.txt @@ -0,0 +1,29 @@ +### What it does +Checks for excessive +use of bools in structs. + +### Why is this bad? +Excessive bools in a struct +is often a sign that it's used as a state machine, +which is much better implemented as an enum. +If it's not the case, excessive bools usually benefit +from refactoring into two-variant enums for better +readability and API. + +### Example +``` +struct S { + is_pending: bool, + is_processing: bool, + is_finished: bool, +} +``` + +Use instead: +``` +enum S { + Pending, + Processing, + Finished, +} +```
\ No newline at end of file |