summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-27 14:20:14 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2021-09-30 08:31:08 +0300
commitd54c6eeda41a2d5d272f8bd24b616aca646b683f (patch)
treef8e16ea9a3d1d78d7278023eacf0d64cc0cd7299
parent6f21483fda6c2e46c056977e4bdb0b9fe940d03a (diff)
Use Result::map or ::map_err instead of ::and_then
Instead of: foo().and_then(|x| Ok(x.transmogrify()) use this: foo().map(|x| x.transmogrify) because it's shorter and simpler to understand. Suggested by clippy lint bind_instead_of_map: https://rust-lang.github.io/rust-clippy/master/index.html#bind_instead_of_map
-rw-r--r--openpgp/src/cert/amalgamation/key.rs6
-rw-r--r--openpgp/src/parse.rs8
2 files changed, 7 insertions, 7 deletions
diff --git a/openpgp/src/cert/amalgamation/key.rs b/openpgp/src/cert/amalgamation/key.rs
index a0614340..bd371ce9 100644
--- a/openpgp/src/cert/amalgamation/key.rs
+++ b/openpgp/src/cert/amalgamation/key.rs
@@ -788,15 +788,15 @@ impl<'a, P: 'a + key::KeyParts> ErasedKeyAmalgamation<'a, P> {
// Look for direct key signatures.
self.cert().primary_key().bundle()
.binding_signature(policy, time)
- .or_else(|e1| {
+ .map_err(|e1| {
// Both lookups failed. Keep the more
// meaningful error.
if let Some(Error::NoBindingSignature(_))
= e1.downcast_ref()
{
- Err(e0) // Return the original error.
+ e0 // Return the original error.
} else {
- Err(e1)
+ e1
}
})
})
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index cae96fc8..8a323b89 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -2052,8 +2052,8 @@ fn one_pass_sig_parser_test () {
impl<'a> Parse<'a, OnePassSig3> for OnePassSig3 {
fn from_reader<R: 'a + Read + Send + Sync>(reader: R) -> Result<Self> {
- OnePassSig::from_reader(reader).and_then(|p| match p {
- OnePassSig::V3(p) => Ok(p),
+ OnePassSig::from_reader(reader).map(|p| match p {
+ OnePassSig::V3(p) => p,
// XXX: Once we have a second variant.
//
// p => Err(Error::InvalidOperation(
@@ -2992,8 +2992,8 @@ impl PKESK3 {
impl<'a> Parse<'a, PKESK3> for PKESK3 {
fn from_reader<R: 'a + Read + Send + Sync>(reader: R) -> Result<Self> {
- PKESK::from_reader(reader).and_then(|p| match p {
- PKESK::V3(p) => Ok(p),
+ PKESK::from_reader(reader).map(|p| match p {
+ PKESK::V3(p) => p,
// XXX: Once we have a second variant.
//
// p => Err(Error::InvalidOperation(