Warn about the risks of using catch-all patterns (#200)

This commit is contained in:
Daniel Wagner-Hall 2024-12-18 10:05:01 +00:00 committed by GitHub
parent fd6a56fd84
commit ab1eb5d80c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -68,3 +68,10 @@ match status {
```
The `_` pattern matches anything that wasn't matched by the previous patterns.
<div class="warning">
By using this catch-all pattern, you _won't_ get the benefits of compiler-driven refactoring.\
If you add a new enum variant, the compiler _won't_ tell you that you're not handling it.
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.
</div>