summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipc/src/assuan/mod.rs15
-rw-r--r--openpgp/src/armor.rs10
-rw-r--r--openpgp/src/cert/amalgamation/key.rs11
-rw-r--r--openpgp/src/cert/parser/mod.rs36
-rw-r--r--openpgp/src/crypto/s2k.rs6
-rw-r--r--openpgp/src/keyhandle.rs8
-rw-r--r--openpgp/src/message/mod.rs34
-rw-r--r--openpgp/src/packet/key.rs5
-rw-r--r--openpgp/src/packet/signature.rs5
-rw-r--r--openpgp/src/packet/signature/subpacket.rs8
-rw-r--r--openpgp/src/parse.rs6
-rw-r--r--openpgp/src/policy.rs7
-rw-r--r--openpgp/src/regex/mod.rs6
-rw-r--r--openpgp/src/serialize/stream.rs8
-rw-r--r--openpgp/src/types/mod.rs23
-rw-r--r--sq/src/commands/key.rs14
16 files changed, 64 insertions, 138 deletions
diff --git a/ipc/src/assuan/mod.rs b/ipc/src/assuan/mod.rs
index 0e503308..a3276210 100644
--- a/ipc/src/assuan/mod.rs
+++ b/ipc/src/assuan/mod.rs
@@ -416,26 +416,17 @@ impl Response {
/// Returns true if this message indicates success.
pub fn is_ok(&self) -> bool {
- match self {
- Response::Ok { .. } => true,
- _ => false,
- }
+ matches!(self, Response::Ok { .. } )
}
/// Returns true if this message indicates an error.
pub fn is_err(&self) -> bool {
- match self {
- Response::Error { .. } => true,
- _ => false,
- }
+ matches!(self, Response::Error { .. })
}
/// Returns true if this message is an inquiry.
pub fn is_inquire(&self) -> bool {
- match self {
- Response::Inquire { .. } => true,
- _ => false,
- }
+ matches!(self, Response::Inquire { .. })
}
/// Returns true if this response concludes the server's response.
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs
index 3ac9886a..1ba52ae9 100644
--- a/openpgp/src/armor.rs
+++ b/openpgp/src/armor.rs
@@ -884,14 +884,12 @@ impl<'a> Reader<'a> {
lines += 1;
// Ignore leading whitespace, etc.
- while match self.source.data_hard(1)?[0] {
+ while matches!(self.source.data_hard(1)?[0],
// Skip some whitespace (previously .is_ascii_whitespace())
- b' ' | b'\t' | b'\r' | b'\n' => true,
+ b' ' | b'\t' | b'\r' | b'\n' |
// Also skip common quote characters
- b'>' | b'|' | b']' | b'}' => true,
- // Do not skip anything else
- _ => false,
- } {
+ b'>' | b'|' | b']' | b'}' )
+ {
let c = self.source.data(1)?[0];
if c == b'\n' {
// We found a newline while walking whitespace, reset prefix
diff --git a/openpgp/src/cert/amalgamation/key.rs b/openpgp/src/cert/amalgamation/key.rs
index 40c0fa33..7e6a1d20 100644
--- a/openpgp/src/cert/amalgamation/key.rs
+++ b/openpgp/src/cert/amalgamation/key.rs
@@ -2346,13 +2346,10 @@ mod test {
// Remove the direct key signatures.
let cert = Cert::from_packets(Vec::from(cert)
.into_iter()
- .filter(|p| {
- match p {
- Packet::Signature(s)
- if s.typ() == SignatureType::DirectKey => false,
- _ => true,
- }
- }))?;
+ .filter(|p| ! matches!(
+ p,
+ Packet::Signature(s) if s.typ() == SignatureType::DirectKey
+ )))?;
let vc = cert.with_policy(p, None)?;
diff --git a/openpgp/src/cert/parser/mod.rs b/openpgp/src/cert/parser/mod.rs
index 6b7369a9..9e888e58 100644
--- a/openpgp/src/cert/parser/mod.rs
+++ b/openpgp/src/cert/parser/mod.rs
@@ -51,11 +51,7 @@ impl KeyringValidity {
/// Note: a `KeyringValidator` will only return this after
/// `KeyringValidator::finish` has been called.
pub fn is_keyring(&self) -> bool {
- if let KeyringValidity::Keyring = self {
- true
- } else {
- false
- }
+ matches!(self, KeyringValidity::Keyring)
}
/// Returns whether the packet sequence is a valid Keyring prefix.
@@ -63,21 +59,13 @@ impl KeyringValidity {
/// Note: a `KeyringValidator` will only return this before
/// `KeyringValidator::finish` has been called.
pub fn is_keyring_prefix(&self) -> bool {
- if let KeyringValidity::KeyringPrefix = self {
- true
- } else {
- false
- }
+ matches!(self, KeyringValidity::KeyringPrefix)
}
/// Returns whether the packet sequence is definitely not a valid
/// keyring.
pub fn is_err(&self) -> bool {
- if let KeyringValidity::Error(_) = self {
- true
- } else {
- false
- }
+ matches!(self, KeyringValidity::Error(_))
}
}
@@ -257,11 +245,7 @@ impl CertValidity {
/// Note: a `CertValidator` will only return this after
/// `CertValidator::finish` has been called.
pub fn is_cert(&self) -> bool {
- if let CertValidity::Cert = self {
- true
- } else {
- false
- }
+ matches!(self, CertValidity::Cert)
}
/// Returns whether the packet sequence is a valid Cert prefix.
@@ -269,21 +253,13 @@ impl CertValidity {
/// Note: a `CertValidator` will only return this before
/// `CertValidator::finish` has been called.
pub fn is_cert_prefix(&self) -> bool {
- if let CertValidity::CertPrefix = self {
- true
- } else {
- false
- }
+ matches!(self, CertValidity::CertPrefix)
}
/// Returns whether the packet sequence is definitely not a valid
/// Cert.
pub fn is_err(&self) -> bool {
- if let CertValidity::Error(_) = self {
- true
- } else {
- false
- }
+ matches!(self, CertValidity::Error(_))
}
}
diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs
index eae95b90..72bd4466 100644
--- a/openpgp/src/crypto/s2k.rs
+++ b/openpgp/src/crypto/s2k.rs
@@ -245,10 +245,8 @@ impl S2K {
/// Returns whether this S2K mechanism is supported.
pub fn is_supported(&self) -> bool {
use self::S2K::*;
- #[allow(deprecated)]
- match self {
- Simple { .. } | Salted { .. } | Iterated { .. } => true,
- _ => false,
+ #[allow(deprecated)] {
+ matches!(self, Simple { .. } | Salted { .. } | Iterated { .. })
}
}
diff --git a/openpgp/src/keyhandle.rs b/openpgp/src/keyhandle.rs
index 607cb60f..e1afb93b 100644
--- a/openpgp/src/keyhandle.rs
+++ b/openpgp/src/keyhandle.rs
@@ -333,11 +333,9 @@ impl KeyHandle {
/// # Ok(()) }
/// ```
pub fn is_invalid(&self) -> bool {
- match self {
- KeyHandle::Fingerprint(Fingerprint::Invalid(_)) => true,
- KeyHandle::KeyID(KeyID::Invalid(_)) => true,
- _ => false,
- }
+ matches!(self,
+ KeyHandle::Fingerprint(Fingerprint::Invalid(_))
+ | KeyHandle::KeyID(KeyID::Invalid(_)))
}
/// Converts this `KeyHandle` to its canonical hexadecimal
diff --git a/openpgp/src/message/mod.rs b/openpgp/src/message/mod.rs
index 3a2903d6..b4ace1aa 100644
--- a/openpgp/src/message/mod.rs
+++ b/openpgp/src/message/mod.rs
@@ -88,11 +88,7 @@ impl MessageValidity {
/// Note: a `MessageValidator` will only return this after
/// `MessageValidator::finish` has been called.
pub fn is_message(&self) -> bool {
- if let MessageValidity::Message = self {
- true
- } else {
- false
- }
+ matches!(self, MessageValidity::Message)
}
/// Returns whether the packet sequence forms a valid message
@@ -101,21 +97,13 @@ impl MessageValidity {
/// Note: a `MessageValidator` will only return this before
/// `MessageValidator::finish` has been called.
pub fn is_message_prefix(&self) -> bool {
- if let MessageValidity::MessagePrefix = self {
- true
- } else {
- false
- }
+ matches!(self, MessageValidity::MessagePrefix)
}
/// Returns whether the packet sequence is definitely not a valid
/// OpenPGP Message.
pub fn is_err(&self) -> bool {
- if let MessageValidity::Error(_) = self {
- true
- } else {
- false
- }
+ matches!(self, MessageValidity::Error(_))
}
}
@@ -1194,7 +1182,7 @@ mod tests {
let mut l = MessageValidator::new();
l.push_token(Token::Literal, &[0]);
l.finish();
- assert!(if let MessageValidity::Message = l.check() { true } else { false });
+ assert!(matches!(l.check(), MessageValidity::Message));
}
#[test]
@@ -1205,7 +1193,7 @@ mod tests {
l.push_token(Token::Literal, &[0]);
l.finish();
- assert!(if let MessageValidity::Message = l.check() { true } else { false });
+ assert!(matches!(l.check(), MessageValidity::Message));
}
#[test]
@@ -1217,7 +1205,7 @@ mod tests {
l.push(Tag::Literal, &[0]);
l.finish();
- assert!(if let MessageValidity::Message = l.check() { true } else { false });
+ assert!(matches!(l.check(), MessageValidity::Message));
}
#[test]
@@ -1227,7 +1215,7 @@ mod tests {
let mut l = MessageValidator::new();
l.finish();
- assert!(if let MessageValidity::Error(_) = l.check() { true } else { false });
+ assert!(matches!(l.check(), MessageValidity::Error(_)));
}
#[test]
@@ -1237,17 +1225,17 @@ mod tests {
// No packets will return an error.
let mut l = MessageValidator::new();
- assert!(if let MessageValidity::MessagePrefix = l.check() { true } else { false });
+ assert!(matches!(l.check(), MessageValidity::MessagePrefix));
l.finish();
- assert!(if let MessageValidity::Error(_) = l.check() { true } else { false });
+ assert!(matches!(l.check(), MessageValidity::Error(_)));
// Simple one-literal message.
let mut l = MessageValidator::new();
l.push(Tag::Literal, &[0]);
- assert!(if let MessageValidity::MessagePrefix = l.check() { true } else { false });
+ assert!(matches!(l.check(), MessageValidity::MessagePrefix));
l.finish();
- assert!(if let MessageValidity::Message = l.check() { true } else { false });
+ assert!(matches!(l.check(), MessageValidity::Message));
}
}
diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs
index 084ec50c..377a8204 100644
--- a/openpgp/src/packet/key.rs
+++ b/openpgp/src/packet/key.rs
@@ -1100,10 +1100,7 @@ impl<P, R> Key4<P, R>
/// This returns false if the `Key` doesn't contain any secret key
/// material.
pub fn has_unencrypted_secret(&self) -> bool {
- match self.secret {
- Some(SecretKeyMaterial::Unencrypted { .. }) => true,
- _ => false,
- }
+ matches!(self.secret, Some(SecretKeyMaterial::Unencrypted { .. }))
}
/// Returns `Key`'s secret key material, if any.
diff --git a/openpgp/src/packet/signature.rs b/openpgp/src/packet/signature.rs
index eaa0c4a4..0b1694e4 100644
--- a/openpgp/src/packet/signature.rs
+++ b/openpgp/src/packet/signature.rs
@@ -2229,10 +2229,7 @@ impl crate::packet::Signature {
// Filters subpackets that usually are in the unhashed area.
fn prefer(p: &Subpacket) -> bool {
use SubpacketTag::*;
- match p.tag() {
- Issuer | EmbeddedSignature | IssuerFingerprint => true,
- _ => false,
- }
+ matches!(p.tag(), Issuer | EmbeddedSignature | IssuerFingerprint)
}
// Collect subpackets keeping track of the size.
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs
index fc619848..abfe694d 100644
--- a/openpgp/src/packet/signature/subpacket.rs
+++ b/openpgp/src/packet/signature/subpacket.rs
@@ -5458,11 +5458,9 @@ impl signature::SignatureBuilder {
F: Into<Option<NotationDataFlags>>,
{
self.hashed_area.packets.retain(|s| {
- match s.value {
- SubpacketValue::NotationData(ref v)
- if v.name == name.as_ref() => false,
- _ => true,
- }
+ ! matches!(
+ s.value,
+ SubpacketValue::NotationData(ref v) if v.name == name.as_ref())
});
self.add_notation(name.as_ref(), value.as_ref(),
flags.into().unwrap_or_else(NotationDataFlags::empty),
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index f27a2bef..3fc136c2 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -3626,11 +3626,7 @@ assert_send_and_sync!(PacketParserResult<'_>);
impl<'a> PacketParserResult<'a> {
/// Returns `true` if the result is `EOF`.
pub fn is_eof(&self) -> bool {
- if let PacketParserResult::EOF(_) = self {
- true
- } else {
- false
- }
+ matches!(self, PacketParserResult::EOF(_))
}
/// Returns `true` if the result is `Some`.
diff --git a/openpgp/src/policy.rs b/openpgp/src/policy.rs
index c915d06d..ee006161 100644
--- a/openpgp/src/policy.rs
+++ b/openpgp/src/policy.rs
@@ -1292,12 +1292,9 @@ impl<'a> Policy for StandardPolicy<'a> {
fn signature(&self, sig: &Signature, sec: HashAlgoSecurity) -> Result<()> {
let time = self.time.unwrap_or_else(Timestamp::now);
- let rev = match sig.typ() {
- SignatureType::KeyRevocation
+ let rev = matches!(sig.typ(), SignatureType::KeyRevocation
| SignatureType::SubkeyRevocation
- | SignatureType::CertificationRevocation => true,
- _ => false,
- };
+ | SignatureType::CertificationRevocation);
// Note: collision resistance requires 2nd pre-image resistance.
if sec == HashAlgoSecurity::CollisionResistance {
diff --git a/openpgp/src/regex/mod.rs b/openpgp/src/regex/mod.rs
index 1e9e3d7d..6d3cd408 100644
--- a/openpgp/src/regex/mod.rs
+++ b/openpgp/src/regex/mod.rs
@@ -923,11 +923,7 @@ impl RegexSet {
/// # Ok(()) }
/// ```
pub fn matches_everything(&self) -> bool {
- if let RegexSet_::Everything = self.re_set {
- true
- } else {
- false
- }
+ matches!(self.re_set, RegexSet_::Everything)
}
/// Controls whether strings with control characters are allowed.
diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs
index 7c4eee5c..1bc4b507 100644
--- a/openpgp/src/serialize/stream.rs
+++ b/openpgp/src/serialize/stream.rs
@@ -1669,14 +1669,10 @@ impl<'a> LiteralWriter<'a> {
// Signer, and if so, we pop it off the stack and
// store it in 'self.signature_writer'.
let signer_above =
- if let &Cookie {
+ matches!(self.inner.cookie_ref(), &Cookie {
private: Private::Signer{..},
..
- } = self.inner.cookie_ref() {
- true
- } else {
- false
- };
+ });
if signer_above {
let stack = self.inner.pop()?;
diff --git a/openpgp/src/types/mod.rs b/openpgp/src/types/mod.rs
index 12ba45c2..9c33f47a 100644
--- a/openpgp/src/types/mod.rs
+++ b/openpgp/src/types/mod.rs
@@ -145,11 +145,13 @@ impl PublicKeyAlgorithm {
/// ```
pub fn for_signing(&self) -> bool {
use self::PublicKeyAlgorithm::*;
- #[allow(deprecated)]
- match &self {
- RSAEncryptSign | RSASign | DSA | ECDSA | ElGamalEncryptSign
- | EdDSA => true,
- _ => false,
+ #[allow(deprecated)] {
+ matches!(self, RSAEncryptSign
+ | RSASign
+ | DSA
+ | ECDSA
+ | ElGamalEncryptSign
+ | EdDSA)
}
}
@@ -167,11 +169,12 @@ impl PublicKeyAlgorithm {
/// ```
pub fn for_encryption(&self) -> bool {
use self::PublicKeyAlgorithm::*;
- #[allow(deprecated)]
- match &self {
- RSAEncryptSign | RSAEncrypt | ElGamalEncrypt | ECDH
- | ElGamalEncryptSign => true,
- _ => false,
+ #[allow(deprecated)] {
+ matches!(self, RSAEncryptSign
+ | RSAEncrypt
+ | ElGamalEncrypt
+ | ECDH
+ | ElGamalEncryptSign)
}
}
diff --git a/sq/src/commands/key.rs b/sq/src/commands/key.rs
index 9a619ab8..cd3cf4ef 100644
--- a/sq/src/commands/key.rs
+++ b/sq/src/commands/key.rs
@@ -451,14 +451,14 @@ fn attest_certifications(config: Config, m: &ArgMatches)
let input = open_or_stdin(m.value_of("key"))?;
let key = Cert::from_reader(input)?;
- // First, remove all attestations.
- let key = Cert::from_packets(
- key.into_packets().filter(|p| match p {
- Packet::Signature(s) if s.typ() == SignatureType__AttestedKey =>
- false,
- _ => true,
- }))?;
+ // First, remove all attestations.
+ let key = Cert::from_packets(key.into_packets().filter(|p| {
+ !matches!(
+ p,
+ Packet::Signature(s) if s.typ() == SignatureType__AttestedKey
+ )
+ }))?;
// Get a signer.
let mut passwords = Vec::new();