Skip to content

Commit ab1eb5d

Browse files
authored
Warn about the risks of using catch-all patterns (#200)
1 parent fd6a56f commit ab1eb5d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

book/src/05_ticket_v2/02_match.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,10 @@ match status {
6868
```
6969

7070
The `_` pattern matches anything that wasn't matched by the previous patterns.
71+
72+
<div class="warning">
73+
By using this catch-all pattern, you _won't_ get the benefits of compiler-driven refactoring.\
74+
If you add a new enum variant, the compiler _won't_ tell you that you're not handling it.
75+
76+
If you're keen on correctness, avoid using catch-alls. Leverage the compiler to re-examine all matching sites and determine how new enum variants should be handled.
77+
</div>

0 commit comments

Comments
 (0)