Skip to content

Commit a0e7651

Browse files
Andreas Schmidtmarcoieni
Andreas Schmidt
andauthoredJan 6, 2021
Add note on #[non_exhaustive] for enums (#168)
Co-authored-by: Marco Ieni <11428655+MarcoIeni@users.noreply.github.com>
1 parent 3ee9110 commit a0e7651

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed
 

‎idioms/priv-extend.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ You can use the `()` type so that there is no runtime overhead and prepend `_` t
3838
If Rust allowed private variants of enums, we could use the same trick to make adding a variant to an enum backwards compatible.
3939
The problem there is exhaustive match expressions.
4040
A private variant would force clients to have a `_` wildcard pattern.
41+
A common way to implement this instead is using the [#[non_exhaustive]](https://doc.rust-lang.org/reference/attributes/type_system.html) attribute.

0 commit comments

Comments
 (0)