summaryrefslogtreecommitdiffstats
path: root/openpgp/src/cert.rs
diff options
context:
space:
mode:
authorIgor Matuszewski <igor@sequoia-pgp.org>2020-10-26 22:37:09 +0100
committerIgor Matuszewski <igor@sequoia-pgp.org>2020-10-26 22:53:50 +0100
commit0f1fc8e2e62fb6da00d3249949b233fbe6d69a6b (patch)
treeb620c1515189725a6b00787063235dfcb4f20356 /openpgp/src/cert.rs
parent4f8dfa8663026d02a778776843f29962339e0c75 (diff)
openpgp: Use std::matches! instead of custom destructures_to macro
Diffstat (limited to 'openpgp/src/cert.rs')
-rw-r--r--openpgp/src/cert.rs41
1 files changed, 24 insertions, 17 deletions
diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs
index abcc3ae5..62cce750 100644
--- a/openpgp/src/cert.rs
+++ b/openpgp/src/cert.rs
@@ -4432,15 +4432,19 @@ mod test {
fn cert_revoked<T>(p: &dyn Policy, cert: &Cert, t: T) -> bool
where T: Into<Option<time::SystemTime>>
{
- !destructures_to!(RevocationStatus::NotAsFarAsWeKnow
- = cert.revocation_status(p, t))
+ !matches!(
+ cert.revocation_status(p, t),
+ RevocationStatus::NotAsFarAsWeKnow
+ )
}
fn subkey_revoked<T>(p: &dyn Policy, cert: &Cert, t: T) -> bool
where T: Into<Option<time::SystemTime>>
{
- !destructures_to!(RevocationStatus::NotAsFarAsWeKnow
- = cert.subkeys().nth(0).unwrap().bundle().revocation_status(p, t))
+ !matches!(
+ cert.subkeys().nth(0).unwrap().bundle().revocation_status(p, t),
+ RevocationStatus::NotAsFarAsWeKnow
+ )
}
let tests : [(&str, Box<dyn Fn(&dyn Policy, &Cert, _) -> bool>); 2] = [
@@ -5540,27 +5544,30 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
// TryFrom<PacketPile>
let pp = PacketPile::from_bytes(&keyring)?;
- assert!(destructures_to!(
- Error::MalformedCert(_) =
- Cert::try_from(pp.clone()).unwrap_err().downcast().unwrap()));
+ assert!(matches!(
+ Cert::try_from(pp.clone()).unwrap_err().downcast().unwrap(),
+ Error::MalformedCert(_)
+ ));
// Cert::TryFrom<Vec<Packet>>
let v: Vec<Packet> = pp.into();
- assert!(destructures_to!(
- Error::MalformedCert(_) =
- Cert::try_from(v.clone()).unwrap_err().downcast().unwrap()));
+ assert!(matches!(
+ Cert::try_from(v.clone()).unwrap_err().downcast().unwrap(),
+ Error::MalformedCert(_)
+ ));
// Cert::from_packet
- assert!(destructures_to!(
- Error::MalformedCert(_) =
- Cert::from_packets(v.into_iter()).unwrap_err()
- .downcast().unwrap()));
+ assert!(matches!(
+ Cert::from_packets(v.into_iter()).unwrap_err().downcast().unwrap(),
+ Error::MalformedCert(_)
+ ));
// Cert::TryFrom<PacketParserResult>
let ppr = PacketParser::from_bytes(&keyring)?;
- assert!(destructures_to!(
- Error::MalformedCert(_) =
- Cert::try_from(ppr).unwrap_err().downcast().unwrap()));
+ assert!(matches!(
+ Cert::try_from(ppr).unwrap_err().downcast().unwrap(),
+ Error::MalformedCert(_)
+ ));
Ok(())
}