summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorIgor Matuszewski <igor@sequoia-pgp.org>2020-10-26 22:22:50 +0100
committerIgor Matuszewski <igor@sequoia-pgp.org>2020-10-26 22:53:49 +0100
commit4f8dfa8663026d02a778776843f29962339e0c75 (patch)
tree6314f738e2bf434ef68dafa78ce387d31f05105f /ipc
parenteca27cf750d73b729673afeeae64ec204690c0f2 (diff)
ipc: Use std::matches! instead of custom destructures_to macro
Diffstat (limited to 'ipc')
-rw-r--r--ipc/src/lib.rs22
-rw-r--r--ipc/src/sexp.rs36
2 files changed, 24 insertions, 34 deletions
diff --git a/ipc/src/lib.rs b/ipc/src/lib.rs
index 9f6bf339..708a03f2 100644
--- a/ipc/src/lib.rs
+++ b/ipc/src/lib.rs
@@ -62,28 +62,6 @@ use std::thread;
use sequoia_openpgp as openpgp;
use sequoia_core as core;
-// Turns an `if let` into an expression so that it is possible to do
-// things like:
-//
-// ```rust,nocompile
-// if destructures_to(Foo::Bar(_) = value)
-// || destructures_to(Foo::Bam(_) = value) { ... }
-// ```
-// TODO: Replace with `std::matches!` once MSRV is bumped to 1.42.
-#[cfg(test)]
-macro_rules! destructures_to {
- ( $error: pat = $expr:expr ) => {
- {
- let x = $expr;
- if let $error = x {
- true
- } else {
- false
- }
- }
- };
-}
-
#[macro_use] mod trace;
pub mod assuan;
pub mod gnupg;
diff --git a/ipc/src/sexp.rs b/ipc/src/sexp.rs
index 105150bc..ee376f61 100644
--- a/ipc/src/sexp.rs
+++ b/ipc/src/sexp.rs
@@ -420,17 +420,29 @@ mod tests {
#[test]
fn to_signature() {
use openpgp::crypto::mpi::Signature::*;
- assert!(destructures_to!(DSA { .. } = Sexp::from_bytes(
- crate::tests::file("sexp/dsa-signature.sexp")).unwrap()
- .to_signature().unwrap()));
- assert!(destructures_to!(ECDSA { .. } = Sexp::from_bytes(
- crate::tests::file("sexp/ecdsa-signature.sexp")).unwrap()
- .to_signature().unwrap()));
- assert!(destructures_to!(EdDSA { .. } = Sexp::from_bytes(
- crate::tests::file("sexp/eddsa-signature.sexp")).unwrap()
- .to_signature().unwrap()));
- assert!(destructures_to!(RSA { .. } = Sexp::from_bytes(
- crate::tests::file("sexp/rsa-signature.sexp")).unwrap()
- .to_signature().unwrap()));
+ assert!(matches!(
+ Sexp::from_bytes(
+ crate::tests::file("sexp/dsa-signature.sexp")).unwrap()
+ .to_signature().unwrap(),
+ DSA { .. }
+ ));
+ assert!(matches!(
+ Sexp::from_bytes(
+ crate::tests::file("sexp/ecdsa-signature.sexp")).unwrap()
+ .to_signature().unwrap(),
+ ECDSA { .. }
+ ));
+ assert!(matches!(
+ Sexp::from_bytes(
+ crate::tests::file("sexp/eddsa-signature.sexp")).unwrap()
+ .to_signature().unwrap(),
+ EdDSA { .. }
+ ));
+ assert!(matches!(
+ Sexp::from_bytes(
+ crate::tests::file("sexp/rsa-signature.sexp")).unwrap()
+ .to_signature().unwrap(),
+ RSA { .. }
+ ));
}
}