diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-09-27 14:45:12 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@sequoia-pgp.org> | 2021-09-30 08:31:08 +0300 |
commit | 2c87795bd765f50363cdee71013848b1c3138604 (patch) | |
tree | 92e180e4da2954852a1d6e0388f3cefb9098a1cd | |
parent | 1b70924cc49ea1aa36f06acba8561f125439ca1b (diff) |
Use .find() in an iterator
Instead of
iter().filter(|x| pred(x)).next()
use this:
iter().find(|x| pred(x))
This is more to the point, and thus easier to understand.
Found by clippy lint filter_next:
https://rust-lang.github.io/rust-clippy/master/index.html#filter_next
-rw-r--r-- | sq/src/commands/key.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/sq/src/commands/key.rs b/sq/src/commands/key.rs index a6562ef5..fc1c5a85 100644 --- a/sq/src/commands/key.rs +++ b/sq/src/commands/key.rs @@ -420,12 +420,11 @@ fn adopt(config: Config, m: &ArgMatches) -> Result<()> { .into_keypair()?; let backsig = builder.embedded_signatures() - .filter(|backsig| { + .find(|backsig| { (*backsig).clone().verify_primary_key_binding( &cert.primary_key(), &key).is_ok() }) - .next() .map(|sig| SignatureBuilder::from(sig.clone())) .unwrap_or_else(|| { SignatureBuilder::new(SignatureType::PrimaryKeyBinding) |