about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTom <tomw08@gmail.com>2025-03-04 14:33:57 +0000
committertherewillbecode <tomw08@gmail.com>2025-03-06 17:30:16 +0000
commitcc6127bce89c249dec752ea93fb2d31bdfa8ebc3 (patch)
tree97c542802d4eec153772a0138c198a21e15dcc7f
parentcdc1d9d87ab8c50a2ab2771906a1573c061ce02b (diff)
downloadrust-cc6127bce89c249dec752ea93fb2d31bdfa8ebc3.tar.gz
rust-cc6127bce89c249dec752ea93fb2d31bdfa8ebc3.zip
docs: update rationale for excessive-bools
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.
-rw-r--r--clippy_lints/src/excessive_bools.rs17
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