diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-06-11 11:24:44 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-06-11 11:24:44 +0200 |
commit | a4d2e75ea6cf56e57aed397720931b22c7d1a123 (patch) | |
tree | f5d89ea60a4ae0d69658f8dc09fa21ea5d303243 /openpgp/src/fingerprint.rs | |
parent | 6055a98b431321a9dd2f74eb8bca7c0f0907ce4a (diff) |
openpgp: Mark enum Fingerprint as non-exhaustive.
Diffstat (limited to 'openpgp/src/fingerprint.rs')
-rw-r--r-- | openpgp/src/fingerprint.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/openpgp/src/fingerprint.rs b/openpgp/src/fingerprint.rs index 7ed623d1..5cc5907e 100644 --- a/openpgp/src/fingerprint.rs +++ b/openpgp/src/fingerprint.rs @@ -10,13 +10,20 @@ use quickcheck::{Arbitrary, Gen}; /// 4880]. /// /// [Section 12.2 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-12.2 +/// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Hash)] pub enum Fingerprint { /// 20 byte SHA-1 hash. V4([u8;20]), /// Used for holding fingerprints that we don't understand. For /// instance, we don't grok v3 fingerprints. - Invalid(Box<[u8]>) + Invalid(Box<[u8]>), + + /// This marks this enum as non-exhaustive. Do not use this + /// variant. + #[doc(hidden)] __Nonexhaustive, } impl fmt::Display for Fingerprint { @@ -72,6 +79,7 @@ impl Fingerprint { match self { &Fingerprint::V4(ref fp) => fp, &Fingerprint::Invalid(ref fp) => fp, + Fingerprint::__Nonexhaustive => unreachable!(), } } @@ -123,6 +131,7 @@ impl Fingerprint { let raw = match self { &Fingerprint::V4(ref fp) => &fp[..], &Fingerprint::Invalid(ref fp) => &fp[..], + Fingerprint::__Nonexhaustive => unreachable!(), }; // We currently only handle V4 fingerprints, which look like: |