diff options
author | Andrew Gallant <jamslam@gmail.com> | 2018-03-10 09:04:01 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-03-10 09:30:55 -0500 |
commit | 54256515b49595a2ac4c2b218e4ddbb5a4920d9b (patch) | |
tree | 3d0530638a0dfb09d8f89798299ee798d51dc3a6 /globset | |
parent | e2516ed0957b10c0a2d49e5cc402c44f04f30a43 (diff) |
globset: make ErrorKind enum extensible
This commit makes the ErrorKind enum extensible by adding a
__Nonexhaustive variant. Callers should use this as a hint that
exhaustive case analysis isn't possible in a stable way since new
variants may be added in the future without a semver bump.
Diffstat (limited to 'globset')
-rw-r--r-- | globset/src/lib.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/globset/src/lib.rs b/globset/src/lib.rs index fb95ce75..17292b06 100644 --- a/globset/src/lib.rs +++ b/globset/src/lib.rs @@ -163,6 +163,13 @@ pub enum ErrorKind { DanglingEscape, /// An error associated with parsing or compiling a regex. Regex(String), + /// Hints that destructuring should not be exhaustive. + /// + /// This enum may grow additional variants, so this makes sure clients + /// don't count on exhaustive matching. (Otherwise, adding a new variant + /// could break existing code.) + #[doc(hidden)] + __Nonexhaustive, } impl StdError for Error { @@ -210,6 +217,7 @@ impl ErrorKind { "dangling '\\'" } ErrorKind::Regex(ref err) => err, + ErrorKind::__Nonexhaustive => unreachable!(), } } } @@ -240,6 +248,7 @@ impl fmt::Display for ErrorKind { ErrorKind::InvalidRange(s, e) => { write!(f, "invalid range; '{}' > '{}'", s, e) } + ErrorKind::__Nonexhaustive => unreachable!(), } } } |