summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2021-04-07 20:35:38 +0200
committerNora Widdecke <nora@sequoia-pgp.org>2021-04-09 13:13:59 +0200
commit73b3321d98e0298dba5d4ef63e8058a01cc2943c (patch)
tree0b5ef2427f8d95085c2819c8e9dba02c3c6f0c65
parent19169b76117db8b1d81f1aafa64a5440d042803d (diff)
Lint: Use next instead of nth(0).
- https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth_zero
-rw-r--r--ffi-macros/src/lib.rs2
-rw-r--r--ipc/src/sexp.rs4
-rw-r--r--openpgp-ffi/src/packet/signature.rs4
-rw-r--r--openpgp/examples/generate-encrypt-decrypt.rs2
-rw-r--r--openpgp/examples/generate-sign-verify.rs2
-rw-r--r--openpgp/src/cert.rs68
-rw-r--r--openpgp/src/cert/amalgamation.rs2
-rw-r--r--openpgp/src/cert/amalgamation/key.rs2
-rw-r--r--openpgp/src/cert/builder.rs6
-rw-r--r--openpgp/src/cert/parser/mod.rs4
-rw-r--r--openpgp/src/crypto/backend/sha1cd.rs4
-rw-r--r--openpgp/src/packet/one_pass_sig.rs2
-rw-r--r--openpgp/src/packet/signature.rs28
-rw-r--r--openpgp/src/packet/signature/subpacket.rs10
-rw-r--r--openpgp/src/packet/userid.rs2
-rw-r--r--openpgp/src/parse.rs3
-rw-r--r--openpgp/src/parse/stream.rs4
-rw-r--r--openpgp/src/policy.rs6
-rw-r--r--openpgp/src/serialize/cert.rs6
-rw-r--r--openpgp/src/serialize/stream.rs7
-rw-r--r--sq/build.rs2
-rw-r--r--sq/src/commands/inspect.rs2
-rw-r--r--sq/src/commands/key.rs2
-rw-r--r--sq/src/commands/keyring.rs4
-rw-r--r--sq/tests/sq-sign.rs2
-rw-r--r--sqv/build.rs2
26 files changed, 89 insertions, 93 deletions
diff --git a/ffi-macros/src/lib.rs b/ffi-macros/src/lib.rs
index 6f0ca859..c4bb0269 100644
--- a/ffi-macros/src/lib.rs
+++ b/ffi-macros/src/lib.rs
@@ -393,7 +393,7 @@ fn derive_conversion_functions(mut st: syn::ItemStruct,
let generics = &st.generics;
let ref_lifetime = if generics.lifetimes().count() > 0 {
- generics.lifetimes().nth(0).unwrap().clone()
+ generics.lifetimes().next().unwrap().clone()
} else {
syn::parse_quote!('static)
};
diff --git a/ipc/src/sexp.rs b/ipc/src/sexp.rs
index 3d25862d..2290b615 100644
--- a/ipc/src/sexp.rs
+++ b/ipc/src/sexp.rs
@@ -64,7 +64,7 @@ impl Sexp {
};
let value = self.get(b"value")?.ok_or_else(not_a_session_key)?
- .into_iter().nth(0).ok_or_else(not_a_session_key)?;
+ .into_iter().next().ok_or_else(not_a_session_key)?;
match value {
Sexp::String(ref s) => match recipient.mpis() {
@@ -153,7 +153,7 @@ impl Sexp {
};
let sig = self.get(b"sig-val")?.ok_or_else(not_a_signature)?
- .into_iter().nth(0).ok_or_else(not_a_signature)?;
+ .into_iter().next().ok_or_else(not_a_signature)?;
if let Some(param) = sig.get(b"eddsa")? {
let r = param.iter().find_map(|p| {
diff --git a/openpgp-ffi/src/packet/signature.rs b/openpgp-ffi/src/packet/signature.rs
index b6d611f9..0cb34fa5 100644
--- a/openpgp-ffi/src/packet/signature.rs
+++ b/openpgp-ffi/src/packet/signature.rs
@@ -53,7 +53,7 @@ fn pgp_signature_into_packet(s: *mut Signature) -> *mut Packet {
/// subpacket, this still returns NULL.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_signature_issuer(sig: *const Signature) -> Maybe<KeyID> {
- sig.ref_raw().issuers().nth(0).move_into_raw()
+ sig.ref_raw().issuers().next().move_into_raw()
}
/// Returns the value of the `Signature` packet's IssuerFingerprint subpacket.
@@ -64,7 +64,7 @@ fn pgp_signature_issuer(sig: *const Signature) -> Maybe<KeyID> {
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_signature_issuer_fingerprint(sig: *const Signature)
-> Maybe<Fingerprint> {
- sig.ref_raw().issuer_fingerprints().nth(0).move_into_raw()
+ sig.ref_raw().issuer_fingerprints().next().move_into_raw()
}
diff --git a/openpgp/examples/generate-encrypt-decrypt.rs b/openpgp/examples/generate-encrypt-decrypt.rs
index b16f6da4..bd8e1dfa 100644
--- a/openpgp/examples/generate-encrypt-decrypt.rs
+++ b/openpgp/examples/generate-encrypt-decrypt.rs
@@ -125,7 +125,7 @@ impl<'a> DecryptionHelper for Helper<'a> {
{
let key = self.secret.keys().unencrypted_secret()
.with_policy(self.policy, None)
- .for_transport_encryption().nth(0).unwrap().key().clone();
+ .for_transport_encryption().next().unwrap().key().clone();
// The secret key is not encrypted.
let mut pair = key.into_keypair()?;
diff --git a/openpgp/examples/generate-sign-verify.rs b/openpgp/examples/generate-sign-verify.rs
index 3a7e89f2..c14052d2 100644
--- a/openpgp/examples/generate-sign-verify.rs
+++ b/openpgp/examples/generate-sign-verify.rs
@@ -51,7 +51,7 @@ fn sign(p: &dyn Policy, sink: &mut (dyn Write + Send + Sync),
let keypair = tsk
.keys().unencrypted_secret()
.with_policy(p, None).supported().alive().revoked(false).for_signing()
- .nth(0).unwrap().key().clone().into_keypair()?;
+ .next().unwrap().key().clone().into_keypair()?;
// Start streaming an OpenPGP message.
let message = Message::new(sink);
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();