diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2021-04-07 20:35:38 +0200 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2021-04-09 13:13:59 +0200 |
commit | 73b3321d98e0298dba5d4ef63e8058a01cc2943c (patch) | |
tree | 0b5ef2427f8d95085c2819c8e9dba02c3c6f0c65 /openpgp/src | |
parent | 19169b76117db8b1d81f1aafa64a5440d042803d (diff) |
Lint: Use next instead of nth(0).
- https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth_zero
Diffstat (limited to 'openpgp/src')
-rw-r--r-- | openpgp/src/cert.rs | 68 | ||||
-rw-r--r-- | openpgp/src/cert/amalgamation.rs | 2 | ||||
-rw-r--r-- | openpgp/src/cert/amalgamation/key.rs | 2 | ||||
-rw-r--r-- | openpgp/src/cert/builder.rs | 6 | ||||
-rw-r--r-- | openpgp/src/cert/parser/mod.rs | 4 | ||||
-rw-r--r-- | openpgp/src/crypto/backend/sha1cd.rs | 4 | ||||
-rw-r--r-- | openpgp/src/packet/one_pass_sig.rs | 2 | ||||
-rw-r--r-- | openpgp/src/packet/signature.rs | 28 | ||||
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 10 | ||||
-rw-r--r-- | openpgp/src/packet/userid.rs | 2 | ||||
-rw-r--r-- | openpgp/src/parse.rs | 3 | ||||
-rw-r--r-- | openpgp/src/parse/stream.rs | 4 | ||||
-rw-r--r-- | openpgp/src/policy.rs | 6 | ||||
-rw-r--r-- | openpgp/src/serialize/cert.rs | 6 | ||||
-rw-r--r-- | openpgp/src/serialize/stream.rs | 7 |
15 files changed, 75 insertions, 79 deletions
diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs index 6c4f1ac9..eb87299e 100644 --- a/openpgp/src/cert.rs +++ b/openpgp/src/cert.rs @@ -4387,7 +4387,7 @@ mod test { .generate().unwrap(); let sig = { - let subkey = cert.subkeys().nth(0).unwrap(); + let subkey = cert.subkeys().next().unwrap(); assert_eq!(RevocationStatus::NotAsFarAsWeKnow, subkey.revocation_status(p, None)); @@ -4405,7 +4405,7 @@ mod test { assert_eq!(RevocationStatus::NotAsFarAsWeKnow, cert.revocation_status(p, None)); - let subkey = cert.subkeys().nth(0).unwrap(); + let subkey = cert.subkeys().next().unwrap(); assert_match!(RevocationStatus::Revoked(_) = subkey.revocation_status(p, None)); } @@ -4555,7 +4555,7 @@ mod test { where T: Into<Option<time::SystemTime>> { !matches!( - cert.subkeys().nth(0).unwrap().bundle().revocation_status(p, t), + cert.subkeys().next().unwrap().bundle().revocation_status(p, t), RevocationStatus::NotAsFarAsWeKnow ) } @@ -4663,7 +4663,7 @@ mod test { = cert.revocation_status(p, None)); assert_eq!(cert.user_attributes().count(), 1); - let ua = cert.user_attributes().nth(0).unwrap(); + let ua = cert.user_attributes().next().unwrap(); if revoked { assert_match!(RevocationStatus::Revoked(_) = ua.revocation_status(p, t)); @@ -4908,7 +4908,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= } // Make sure we return the most recent first. - assert_eq!(uid.self_signatures().nth(0).unwrap(), + assert_eq!(uid.self_signatures().next().unwrap(), uid.binding_signature(p, None).unwrap()); } @@ -5212,7 +5212,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= .generate().unwrap(); assert_eq!(bob.userids().len(), 1); - let bob_userid_binding = bob.userids().nth(0).unwrap(); + let bob_userid_binding = bob.userids().next().unwrap(); assert_eq!(bob_userid_binding.userid().value(), b"bob@bar.com"); let sig_template @@ -5233,7 +5233,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= // Make sure the certification is merged, and put in the right // place. assert_eq!(bob.userids().len(), 1); - let bob_userid_binding = bob.userids().nth(0).unwrap(); + let bob_userid_binding = bob.userids().next().unwrap(); assert_eq!(bob_userid_binding.userid().value(), b"bob@bar.com"); // Canonicalizing Bob's cert without having Alice's key @@ -5359,9 +5359,9 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= let cert = cert.insert_packets(vec![Packet::from(fake_key), fake_binding.clone().into()])?; assert_eq!(cert.unknowns().count(), 1); - assert_eq!(cert.unknowns().nth(0).unwrap().unknown().tag(), + assert_eq!(cert.unknowns().next().unwrap().unknown().tag(), packet::Tag::PublicSubkey); - assert_eq!(cert.unknowns().nth(0).unwrap().self_signatures().collect::<Vec<_>>(), + assert_eq!(cert.unknowns().next().unwrap().self_signatures().collect::<Vec<_>>(), vec![&fake_binding]); Ok(()) @@ -5533,7 +5533,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= crate::tests::key("different-preferences.asc"))?; assert_eq!(cert.userids().count(), 2); - if let Some(userid) = cert.userids().nth(0) { + if let Some(userid) = cert.userids().next() { assert_eq!(userid.userid().value(), &b"Alice Confusion <alice@example.com>"[..]); @@ -5562,7 +5562,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= panic!("two user ids"); } - if let Some(userid) = cert.userids().nth(0) { + if let Some(userid) = cert.userids().next() { assert_eq!(userid.userid().value(), &b"Alice Confusion <alice@example.com>"[..]); @@ -5738,8 +5738,8 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= assert_eq!(cert.subkeys().count(), 2); assert_eq!(cert.unknowns().count(), 0); assert_eq!(cert.bad_signatures().count(), 0); - assert_eq!(cert.userids().nth(0).unwrap().self_signatures().count(), 1); - assert_eq!(cert.subkeys().nth(0).unwrap().self_signatures().count(), 1); + assert_eq!(cert.userids().next().unwrap().self_signatures().count(), 1); + assert_eq!(cert.subkeys().next().unwrap().self_signatures().count(), 1); assert_eq!(cert.subkeys().nth(1).unwrap().self_signatures().count(), 1); // Create a variant of cert where the signatures have @@ -5763,8 +5763,8 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= assert_eq!(cert.subkeys().count(), 2); assert_eq!(cert.unknowns().count(), 0); assert_eq!(cert.bad_signatures().count(), 0); - assert_eq!(cert.userids().nth(0).unwrap().self_signatures().count(), 1); - assert_eq!(cert.subkeys().nth(0).unwrap().self_signatures().count(), 1); + assert_eq!(cert.userids().next().unwrap().self_signatures().count(), 1); + assert_eq!(cert.subkeys().next().unwrap().self_signatures().count(), 1); assert_eq!(cert.subkeys().nth(1).unwrap().self_signatures().count(), 1); Ok(()) @@ -5802,7 +5802,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= .sign_primary_key_binding( &mut pair, cert.primary_key().key(), - cert.keys().subkeys().nth(0).unwrap().key())?), + cert.keys().subkeys().next().unwrap().key())?), false)?)?; } else { panic!("expected a signature"); @@ -5850,14 +5850,14 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= if let Some(Packet::Signature(sig)) = pp.path_ref_mut(&[4]) { // Prepend a bad backsig. - let backsig = sig.embedded_signatures().nth(0).unwrap().clone(); + let backsig = sig.embedded_signatures().next().unwrap().clone(); sig.unhashed_area_mut().replace(Subpacket::new( SubpacketValue::EmbeddedSignature( SignatureBuilder::new(SignatureType::PrimaryKeyBinding) .sign_primary_key_binding( &mut pair, cert.primary_key().key(), - cert.keys().subkeys().nth(0).unwrap().key())?), + cert.keys().subkeys().next().unwrap().key())?), false)?)?; sig.unhashed_area_mut().add(Subpacket::new( SubpacketValue::EmbeddedSignature(backsig), false)?)?; @@ -5880,7 +5880,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= assert_eq!(merged.with_policy(p, None)?.keys().subkeys() .for_signing().count(), 1); let sig = merged.with_policy(p, None)?.keys().subkeys() - .for_signing().nth(0).unwrap().binding_signature(); + .for_signing().next().unwrap().binding_signature(); assert_eq!(sig.embedded_signatures().count(), 2); // Now the other way around. @@ -5889,7 +5889,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= assert_eq!(merged.with_policy(p, None)?.keys().subkeys() .for_signing().count(), 1); let sig = merged.with_policy(p, None)?.keys().subkeys() - .for_signing().nth(0).unwrap().binding_signature(); + .for_signing().next().unwrap().binding_signature(); assert_eq!(sig.embedded_signatures().count(), 2); Ok(()) } @@ -5921,11 +5921,11 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= // Specifically, the issuer information should have been added // back by the canonicalization. assert_eq!( - cert.userids().nth(0).unwrap().self_signatures().nth(0).unwrap() + cert.userids().next().unwrap().self_signatures().next().unwrap() .unhashed_area().subpackets(SubpacketTag::Issuer).count(), 1); assert_eq!( - cert.keys().subkeys().nth(0).unwrap().self_signatures().nth(0).unwrap() + cert.keys().subkeys().next().unwrap().self_signatures().next().unwrap() .unhashed_area().subpackets(SubpacketTag::Issuer).count(), 1); Ok(()) @@ -6034,7 +6034,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= // Have Alice certify the binding between "bob@bar.com" and // Bob's key. let alice_certifies_bob - = bob.userids().nth(0).unwrap().userid().bind( + = bob.userids().next().unwrap().userid().bind( &mut alice_signer, &bob, SignatureBuilder::new(SignatureType::GenericCertification))?; @@ -6049,7 +6049,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= // Then, prepare an attested key signature. let mut h = hash_algo.context()?; bob.primary_key().key().hash(&mut h); - bob.userids().nth(0).unwrap().userid().hash(&mut h); + bob.userids().next().unwrap().userid().hash(&mut h); let attestation = SignatureBuilder::new(SignatureType__AttestedKey) .modify_hashed_area(|mut a| { @@ -6069,25 +6069,25 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= ])?; assert_eq!(bob.bad_signatures().count(), 0); - assert_eq!(bob.userids().nth(0).unwrap().certifications().nth(0), + assert_eq!(bob.userids().next().unwrap().certifications().next(), Some(&alice_certifies_bob)); - assert_eq!(&bob.userids().nth(0).unwrap().bundle().attestations[0], + assert_eq!(&bob.userids().next().unwrap().bundle().attestations[0], &attestation); // Check that attested key signatures are kept over merges. let bob_ = bob.clone().merge_public(bob_pristine.clone())?; assert_eq!(bob_.bad_signatures().count(), 0); - assert_eq!(bob_.userids().nth(0).unwrap().certifications().nth(0), + assert_eq!(bob_.userids().next().unwrap().certifications().next(), Some(&alice_certifies_bob)); - assert_eq!(&bob_.userids().nth(0).unwrap().bundle().attestations[0], + assert_eq!(&bob_.userids().next().unwrap().bundle().attestations[0], &attestation); // And the other way around. let bob_ = bob_pristine.clone().merge_public(bob.clone())?; assert_eq!(bob_.bad_signatures().count(), 0); - assert_eq!(bob_.userids().nth(0).unwrap().certifications().nth(0), + assert_eq!(bob_.userids().next().unwrap().certifications().next(), Some(&alice_certifies_bob)); - assert_eq!(&bob_.userids().nth(0).unwrap().bundle().attestations[0], + assert_eq!(&bob_.userids().next().unwrap().bundle().attestations[0], &attestation); Ok(()) @@ -6104,13 +6104,13 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= let test = Cert::from_bytes(crate::tests::key("1pa3pc-dkgpg.pgp"))?; assert_eq!(test.bad_signatures().count(), 0); - assert_eq!(test.userids().nth(0).unwrap().certifications().count(), + assert_eq!(test.userids().next().unwrap().certifications().count(), 1); - assert_eq!(test.userids().nth(0).unwrap().bundle().attestations.len(), + assert_eq!(test.userids().next().unwrap().bundle().attestations.len(), 1); let attestation = - &test.userids().nth(0).unwrap().bundle().attestations[0]; + &test.userids().next().unwrap().bundle().attestations[0]; let digest_size = attestation.hash_algo().context()?.digest_size(); let digests = if let Some(SubpacketValue::Unknown { body, .. }) = @@ -6130,7 +6130,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= } for (i, certification) in - test.userids().nth(0).unwrap().certifications().enumerate() + test.userids().next().unwrap().certifications().enumerate() { // Hash the certification. let mut h = attestation.hash_algo().context()?; diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs index 4447c823..bc5284e0 100644 --- a/openpgp/src/cert/amalgamation.rs +++ b/openpgp/src/cert/amalgamation.rs @@ -1303,7 +1303,7 @@ mod test { .generate() .unwrap(); - let userid : UserIDAmalgamation = cert.userids().nth(0).unwrap(); + let userid : UserIDAmalgamation = cert.userids().next().unwrap(); assert_eq!(userid.userid(), userid.clone().userid()); let userid : ValidUserIDAmalgamation diff --git a/openpgp/src/cert/amalgamation/key.rs b/openpgp/src/cert/amalgamation/key.rs index 7e6a1d20..159348bb 100644 --- a/openpgp/src/cert/amalgamation/key.rs +++ b/openpgp/src/cert/amalgamation/key.rs @@ -2278,7 +2278,7 @@ mod test { let mut primary_signer = cert.primary_key().key().clone() .parts_into_secret().unwrap().into_keypair().unwrap(); let mut signing_subkey_signer = cert.with_policy(p, None).unwrap() - .keys().for_signing().nth(0).unwrap() + .keys().for_signing().next().unwrap() .key().clone().parts_into_secret().unwrap() .into_keypair().unwrap(); diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs index 6117a325..d0147b99 100644 --- a/openpgp/src/cert/builder.rs +++ b/openpgp/src/cert/builder.rs @@ -1311,15 +1311,13 @@ mod tests { assert!(! sig.key_alive(key, now + 610 * s).is_ok()); let ka = cert.keys().with_policy(p, now).alive().revoked(false) - .for_signing() - .nth(0).unwrap(); + .for_signing().next().unwrap(); assert!(ka.alive().is_ok()); assert!(ka.clone().with_policy(p, now + 290 * s).unwrap().alive().is_ok()); assert!(! ka.clone().with_policy(p, now + 310 * s).unwrap().alive().is_ok()); let ka = cert.keys().with_policy(p, now).alive().revoked(false) - .for_authentication() - .nth(0).unwrap(); + .for_authentication().next().unwrap(); assert!(ka.alive().is_ok()); assert!(ka.clone().with_policy(p, now + 590 * s).unwrap().alive().is_ok()); assert!(! ka.clone().with_policy(p, now + 610 * s).unwrap().alive().is_ok()); diff --git a/openpgp/src/cert/parser/mod.rs b/openpgp/src/cert/parser/mod.rs index 31929347..7e5cbf63 100644 --- a/openpgp/src/cert/parser/mod.rs +++ b/openpgp/src/cert/parser/mod.rs @@ -1150,7 +1150,7 @@ mod test { testy_with_marker.extend_from_slice(crate::tests::key("testy.pgp")); CertParser::from( PacketParser::from_bytes(&testy_with_marker).unwrap()) - .nth(0).unwrap().unwrap(); + .next().unwrap().unwrap(); } #[test] @@ -1182,7 +1182,7 @@ mod test { let userid : Packet = cert.clone() .into_iter() .filter(|p| p.tag() == Tag::UserID) - .nth(0) + .next() .unwrap(); // An unknown packet. diff --git a/openpgp/src/crypto/backend/sha1cd.rs b/openpgp/src/crypto/backend/sha1cd.rs index 7daf8ac1..dc511728 100644 --- a/openpgp/src/crypto/backend/sha1cd.rs +++ b/openpgp/src/crypto/backend/sha1cd.rs @@ -69,7 +69,7 @@ mod test { assert_eq!(bob.path_ref(&[6]).unwrap(), alice.path_ref(&[3]).unwrap()); match bob.path_ref(&[6]).unwrap() { Packet::Signature(s) => { - assert_eq!(s.issuers().nth(0).unwrap(), &ca_keyid); + assert_eq!(s.issuers().next().unwrap(), &ca_keyid); }, o => panic!("unexpected packet: {:?}", o), } @@ -116,7 +116,7 @@ mod test { } fn check(&mut self, structure: MessageStructure) -> Result<()> { if let MessageLayer::SignatureGroup { results } = - structure.into_iter().nth(0).unwrap() + structure.into_iter().next().unwrap() { assert_eq!(results.len(), 1); assert!(results[0].is_err()); diff --git a/openpgp/src/packet/one_pass_sig.rs b/openpgp/src/packet/one_pass_sig.rs index 452cc3e7..41903901 100644 --- a/openpgp/src/packet/one_pass_sig.rs +++ b/openpgp/src/packet/one_pass_sig.rs @@ -151,7 +151,7 @@ impl<'a> std::convert::TryFrom<&'a Signature> for OnePassSig3 { type Error = anyhow::Error; fn try_from(s: &'a Signature) -> Result<Self> { - let issuer = match s.issuers().nth(0) { + let issuer = match s.issuers().next() { Some(i) => i.clone(), None => return Err(Error::InvalidArgument( diff --git a/openpgp/src/packet/signature.rs b/openpgp/src/packet/signature.rs index 0b1694e4..2420b236 100644 --- a/openpgp/src/packet/signature.rs +++ b/openpgp/src/packet/signature.rs @@ -3359,13 +3359,13 @@ mod test { crate::tests::key("test1-certification-key.pgp")).unwrap(); let cert_key1 = test1.keys().with_policy(p, None) .for_certification() - .nth(0) + .next() .map(|ka| ka.key()) .unwrap(); let test2 = Cert::from_bytes( crate::tests::key("test2-signed-by-test1.pgp")).unwrap(); - let uid = test2.userids().with_policy(p, None).nth(0).unwrap(); - let mut cert = uid.certifications().nth(0).unwrap().clone(); + let uid = test2.userids().with_policy(p, None).next().unwrap(); + let mut cert = uid.certifications().next().unwrap().clone(); cert.verify_userid_binding(cert_key1, test2.primary_key().key(), @@ -3412,7 +3412,7 @@ mod test { let sig = builder.sign_hash(&mut pair, hash.clone()).unwrap().normalize(); assert_eq!(sig.unhashed_area().iter().count(), 3); - assert_eq!(*sig.unhashed_area().iter().nth(0).unwrap(), + assert_eq!(*sig.unhashed_area().iter().next().unwrap(), Subpacket::new(SubpacketValue::Issuer(keyid.clone()), false).unwrap()); assert_eq!(sig.unhashed_area().iter().nth(1).unwrap().tag(), @@ -3504,17 +3504,17 @@ mod test { let mut primary_signer = alice.primary_key().key().clone() .parts_into_secret()?.into_keypair()?; assert_eq!(alice.userids().len(), 1); - assert_eq!(alice.userids().nth(0).unwrap().self_signatures().count(), 1); + assert_eq!(alice.userids().next().unwrap().self_signatures().count(), 1); let creation_time = - alice.userids().nth(0).unwrap().self_signatures().nth(0).unwrap() + alice.userids().next().unwrap().self_signatures().next().unwrap() .signature_creation_time().unwrap(); for i in 0..2 * SIG_BACKDATE_BY { - assert_eq!(alice.userids().nth(0).unwrap().self_signatures().count(), + assert_eq!(alice.userids().next().unwrap().self_signatures().count(), 1 + i as usize); // Get the binding signature so that we can modify it. - let sig = alice.with_policy(p, None)?.userids().nth(0).unwrap() + let sig = alice.with_policy(p, None)?.userids().next().unwrap() .binding_signature().clone(); assert_eq!(sig.signature_creation_time().unwrap(), creation_time + std::time::Duration::new(i, 0)); @@ -3527,7 +3527,7 @@ mod test { false)? .sign_userid_binding(&mut primary_signer, alice.primary_key().component(), - &alice.userids().nth(0).unwrap()) { + &alice.userids().next().unwrap()) { Ok(v) => v, Err(e) => if i < SIG_BACKDATE_BY { return Err(e); // Not cool. @@ -3542,7 +3542,7 @@ mod test { // Merge it and check that the new binding signature is // the current one. alice = alice.insert_packets(new_sig.clone())?; - let sig = alice.with_policy(p, None)?.userids().nth(0).unwrap() + let sig = alice.with_policy(p, None)?.userids().next().unwrap() .binding_signature(); assert_eq!(sig, &new_sig); } @@ -3598,12 +3598,12 @@ mod test { let cert = Cert::try_from(pp)?; assert_eq!(cert.bad_signatures().count(), 1); assert_eq!(cert.keys().subkeys().count(), 1); - let subkey = cert.keys().subkeys().nth(0).unwrap(); + let subkey = cert.keys().subkeys().next().unwrap(); assert_eq!(subkey.self_signatures().count(), 1); // All the authentic information in the self signature has // been authenticated by the verification process. - let sig = &subkey.self_signatures().nth(0).unwrap(); + let sig = &subkey.self_signatures().next().unwrap(); assert!(sig.hashed_area().iter().all(|p| p.authenticated())); // All but our fake issuer information. assert!(sig.unhashed_area().iter().all(|p| { @@ -3619,12 +3619,12 @@ mod test { } })); // Check the subpackets in the embedded signature. - let sig = sig.embedded_signatures().nth(0).unwrap(); + let sig = sig.embedded_signatures().next().unwrap(); assert!(sig.hashed_area().iter().all(|p| p.authenticated())); assert!(sig.unhashed_area().iter().all(|p| p.authenticated())); // No information in the bad signature has been authenticated. - let sig = cert.bad_signatures().nth(0).unwrap(); + let sig = cert.bad_signatures().next().unwrap(); assert!(sig.hashed_area().iter().all(|p| ! p.authenticated())); assert!(sig.unhashed_area().iter().all(|p| ! p.authenticated())); Ok(()) diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index abfe694d..f2cfd410 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -7006,7 +7006,7 @@ fn accessors() { sig = sig.set_revocation_key(vec![ rk.clone() ]).unwrap(); let sig_ = sig.clone().sign_hash(&mut keypair, hash.clone()).unwrap(); - assert_eq!(sig_.revocation_keys().nth(0).unwrap(), &rk); + assert_eq!(sig_.revocation_keys().next().unwrap(), &rk); sig = sig.set_issuer(fp.clone().into()).unwrap(); let sig_ = @@ -7095,7 +7095,7 @@ fn accessors() { sig = sig.set_embedded_signature(embedded_sig.clone()).unwrap(); let sig_ = sig.clone().sign_hash(&mut keypair, hash.clone()).unwrap(); - assert_eq!(sig_.embedded_signatures().nth(0), Some(&embedded_sig)); + assert_eq!(sig_.embedded_signatures().next(), Some(&embedded_sig)); sig = sig.set_issuer_fingerprint(fp.clone()).unwrap(); let sig_ = @@ -7181,7 +7181,7 @@ fn subpacket_test_1 () { assert!(got2 && got16 && got33); - let hex = format!("{:X}", sig.issuer_fingerprints().nth(0).unwrap()); + let hex = format!("{:X}", sig.issuer_fingerprints().next().unwrap()); assert!( hex == "7FAF6ED7238143557BDF7ED26863C9AD5B4D22D3" || hex == "C03FA6411B03AE12576461187223B56678E02528"); @@ -7231,7 +7231,7 @@ fn subpacket_test_2() { // Test #1 if let (Some(&Packet::PublicKey(ref key)), Some(&Packet::Signature(ref sig))) - = (pile.children().nth(0), pile.children().nth(2)) + = (pile.children().next(), pile.children().nth(2)) { // tag: 2, SignatureCreationTime(1515791508) } // tag: 9, KeyExpirationTime(63072000) } @@ -7491,7 +7491,7 @@ fn subpacket_test_2() { let fp = "361A96BDE1A65B6D6C25AE9FF004B9A45C586126".parse().unwrap(); let rk = RevocationKey::new(PublicKeyAlgorithm::RSAEncryptSign, fp, false); - assert_eq!(sig.revocation_keys().nth(0).unwrap(), &rk); + assert_eq!(sig.revocation_keys().next().unwrap(), &rk); assert_eq!(sig.subpacket(SubpacketTag::RevocationKey), Some(&Subpacket { length: 23.into(), diff --git a/openpgp/src/packet/userid.rs b/openpgp/src/packet/userid.rs index 2994f23e..e2f81a6a 100644 --- a/openpgp/src/packet/userid.rs +++ b/openpgp/src/packet/userid.rs @@ -222,7 +222,7 @@ impl ConventionallyParsedUserID { // The regex is anchored at the start and at the end so we // have either 0 or 1 matches. - if let Some(cap) = USER_ID_PARSER.captures_iter(&userid).nth(0) { + if let Some(cap) = USER_ID_PARSER.captures_iter(&userid).next() { let to_range = |m: regex::Match| (m.start(), m.end()); // We need to figure out which branch matched. Match on a diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs index 8c658746..4a91d7b2 100644 --- a/openpgp/src/parse.rs +++ b/openpgp/src/parse.rs @@ -6052,8 +6052,7 @@ mod test { let cert: Cert = Cert::from_bytes(crate::tests::key("testy-new-private.pgp"))?; let signing_keypair = cert.keys().secret() - .with_policy(p, None).alive().revoked(false).for_signing() - .nth(0).unwrap() + .with_policy(p, None).alive(). |