From ab1eb5d80c9db81e84fca52b349f8657f85a9d60 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 18 Dec 2024 10:05:01 +0000 Subject: [PATCH] Warn about the risks of using catch-all patterns (#200) --- book/src/05_ticket_v2/02_match.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/book/src/05_ticket_v2/02_match.md b/book/src/05_ticket_v2/02_match.md index 8541c7a..9057650 100644 --- a/book/src/05_ticket_v2/02_match.md +++ b/book/src/05_ticket_v2/02_match.md @@ -68,3 +68,10 @@ match status { ``` The `_` pattern matches anything that wasn't matched by the previous patterns. + +
+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. +