1 This error indicates that the struct, enum or enum variant must be matched
2 non-exhaustively as it has been marked as `non_exhaustive`.
4 When applied within a crate, downstream users of the crate will need to use the
5 `_` pattern when matching enums and use the `..` pattern when matching structs.
6 Downstream crates cannot match against non-exhaustive enum variants.
8 For example, in the below example, since the enum is marked as
9 `non_exhaustive`, it is required that downstream crates match non-exhaustively
12 ```rust,ignore (pseudo-Rust)
13 use std::error::Error as StdError;
15 #[non_exhaustive] pub enum Error {
20 impl StdError for Error {
21 fn description(&self) -> &str {
22 // This will not error, despite being marked as non_exhaustive, as this
23 // enum is defined within the current crate, it can be matched
27 Other => "other or unknown error",
33 An example of matching non-exhaustively on the above enum is provided below:
35 ```rust,ignore (pseudo-Rust)
38 // This will not error as the non_exhaustive Error enum has been matched with a
41 Message(ref s) => ...,
47 Similarly, for structs, match with `..` to avoid this error.