diff options
| author | Alejandra González <blyxyas@gmail.com> | 2025-03-06 18:54:55 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-06 18:54:55 +0000 |
| commit | cee9abf10c28711e9a18cf54a5d89b7b5e92f558 (patch) | |
| tree | f1df9186c0e96eb2c176a9422c0f384a3efc6c43 | |
| parent | 81643e297cf44ce3c7648b8443fc4d6592fa81eb (diff) | |
| parent | cc6127bce89c249dec752ea93fb2d31bdfa8ebc3 (diff) | |
docs: update rationale for excessive-bools (#14351)
Adds the reasoning to the docs for this rule on why enums are generally better for representing state machines than structs with many bool fields. changelog: [struct_excessive_bools]: Improve documentation
| -rw-r--r-- | clippy_lints/src/excessive_bools.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/clippy_lints/src/excessive_bools.rs b/clippy_lints/src/excessive_bools.rs index 54a1ac21c85..3b71d2127fa 100644 --- a/clippy_lints/src/excessive_bools.rs +++ b/clippy_lints/src/excessive_bools.rs @@ -15,12 +15,17 @@ declare_clippy_lint! { /// 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. + /// Excessive bools in a struct is often a sign that + /// the type is being used to represent a state + /// machine, which is much better implemented as an + /// enum. + /// + /// The reason an enum is better for state machines + /// over structs is that enums more easily forbid + /// invalid states. + /// + /// Structs with too many booleans may benefit from refactoring + /// into multi variant enums for better readability and API. /// /// ### Example /// ```no_run |
