Skip to content

Commit

Permalink
Use the non_exhaustive feature in CertificateParams
Browse files Browse the repository at this point in the history
This attribute replaces the _hidden field of the
struct, serving the same purpose.

For enums, we don't use the non_exhaustive feature
yet as we'd like to have exhaustivness checks
at least for our internal code.
For more, see this comment by @dtolnay [1]

It stabilized in Rust 1.40.0 which got released today.
The MSRV policy of this crate is to follow whatever
the currently latest released Rust version is.

[1]: rust-lang/rust#44109 (comment)
  • Loading branch information
est31 committed Dec 19, 2019
1 parent 6e25da2 commit d6b84d3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ impl <'a> Iterator for DistinguishedNameIterator<'a> {

/// Parameters used for certificate generation
#[allow(missing_docs)]
#[non_exhaustive]
pub struct CertificateParams {
pub alg :&'static SignatureAlgorithm,
pub not_before :DateTime<Utc>,
Expand All @@ -274,8 +275,6 @@ pub struct CertificateParams {
pub custom_extensions :Vec<CustomExtension>,
/// The certificate's key pair, a new random key pair will be generated if this is `None`
pub key_pair :Option<KeyPair>,
// To make the struct non-exhaustive
_hidden :(),
}

impl Default for CertificateParams {
Expand All @@ -296,7 +295,6 @@ impl Default for CertificateParams {
extended_key_usages : Vec::new(),
custom_extensions : Vec::new(),
key_pair : None,
_hidden :(),
}
}
}
Expand Down

0 comments on commit d6b84d3

Please sign in to comment.