diff options
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/examples/encrypt-for.rs | 4 | ||||
-rw-r--r-- | openpgp/examples/generate-encrypt-decrypt.rs | 4 | ||||
-rw-r--r-- | openpgp/src/serialize/stream.rs | 27 |
3 files changed, 9 insertions, 26 deletions
diff --git a/openpgp/examples/encrypt-for.rs b/openpgp/examples/encrypt-for.rs index d31f2cc9..a7701770 100644 --- a/openpgp/examples/encrypt-for.rs +++ b/openpgp/examples/encrypt-for.rs @@ -37,15 +37,13 @@ fn main() { .expect("Failed to read key") }).collect(); - // Build a vector of recipients to hand to Encryptor. let recipients = certs.iter() .flat_map(|cert| { cert.keys() .with_policy(p, None).alive().revoked(false).key_flags(&mode) }) - .map(|ka| ka.key()) - .collect::<Vec<_>>(); + .map(|ka| ka.key()); // Compose a writer stack corresponding to the output format and // packet structure we want. First, we want the output to be diff --git a/openpgp/examples/generate-encrypt-decrypt.rs b/openpgp/examples/generate-encrypt-decrypt.rs index dba5ebf8..e19c98b0 100644 --- a/openpgp/examples/generate-encrypt-decrypt.rs +++ b/openpgp/examples/generate-encrypt-decrypt.rs @@ -47,12 +47,10 @@ fn encrypt(p: &dyn Policy, sink: &mut dyn Write, plaintext: &str, recipient: &openpgp::Cert) -> openpgp::Result<()> { - // Build a vector of recipients to hand to Encryptor. let recipients = recipient.keys().with_policy(p, None).alive().revoked(false) .for_transport_encryption() - .map(|ka| ka.key()) - .collect::<Vec<_>>(); + .map(|ka| ka.key()); // Start streaming an OpenPGP message. let message = Message::new(sink); diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs index c68c2099..9d95610d 100644 --- a/openpgp/src/serialize/stream.rs +++ b/openpgp/src/serialize/stream.rs @@ -97,14 +97,12 @@ //! //! let recipient: Cert = // ... //! # sender.clone(); -//! // Build a vector of recipients to hand to the `Encryptor`. //! // Note: One certificate may contain several suitable encryption keys. //! let recipients = //! recipient.keys().with_policy(p, None).alive().revoked(false) //! // Or `for_storage_encryption()`, for data at rest. //! .for_transport_encryption() -//! .map(|ka| ka.key()) -//! .collect::<Vec<_>>(); +//! .map(|ka| ka.key()); //! //! # let mut sink = vec![]; //! let message = Message::new(&mut sink); @@ -1858,13 +1856,11 @@ impl<'a> Recipient<'a> { /// # */ /// )?; /// - /// // Build a vector of recipients to hand to the `Encryptor`. /// let recipients = /// cert.keys().with_policy(p, None).alive().revoked(false) /// // Or `for_storage_encryption()`, for data at rest. /// .for_transport_encryption() - /// .map(|ka| ka.key()) - /// .collect::<Vec<_>>(); + /// .map(|ka| ka.key()); /// /// # let mut sink = vec![]; /// let message = Message::new(&mut sink); @@ -1935,7 +1931,6 @@ impl<'a> Recipient<'a> { /// # */ /// )?; /// - /// // Build a vector of recipients to hand to the `Encryptor`. /// let recipients = /// cert.keys().with_policy(p, None).alive().revoked(false) /// // Or `for_storage_encryption()`, for data at rest. @@ -2007,7 +2002,6 @@ impl<'a> Recipient<'a> { /// # */ /// )?; /// - /// // Build a vector of recipients to hand to the `Encryptor`. /// let recipients = /// cert.keys().with_policy(p, None).alive().revoked(false) /// // Or `for_storage_encryption()`, for data at rest. @@ -2017,8 +2011,7 @@ impl<'a> Recipient<'a> { /// // Set the recipient keyid to the wildcard id. /// r.set_keyid(KeyID::wildcard()); /// r - /// }) - /// .collect::<Vec<_>>(); + /// }); /// /// # let mut sink = vec![]; /// let message = Message::new(&mut sink); @@ -2117,13 +2110,11 @@ impl<'a> Encryptor<'a> { /// # */ /// )?; /// - /// // Build a vector of recipients to hand to the `Encryptor`. /// let recipients = /// cert.keys().with_policy(p, None).alive().revoked(false) /// // Or `for_storage_encryption()`, for data at rest. /// .for_transport_encryption() - /// .map(|ka| ka.key()) - /// .collect::<Vec<_>>(); + /// .map(|ka| ka.key()); /// /// # let mut sink = vec![]; /// let message = Message::new(&mut sink); @@ -2252,13 +2243,11 @@ impl<'a> Encryptor<'a> { /// # */ /// )?; /// - /// // Build a vector of recipients to hand to the `Encryptor`. /// let recipients = /// cert.keys().with_policy(p, None).alive().revoked(false) /// // Or `for_storage_encryption()`, for data at rest. /// .for_transport_encryption() - /// .map(|ka| ka.key()) - /// .collect::<Vec<_>>(); + /// .map(|ka| ka.key()); /// /// # let mut sink = vec![]; /// let message = Message::new(&mut sink); @@ -2338,13 +2327,11 @@ impl<'a> Encryptor<'a> { /// # */ /// )?; /// - /// // Build a vector of recipients to hand to the `Encryptor`. /// let recipients = /// cert.keys().with_policy(p, None).alive().revoked(false) /// // Or `for_storage_encryption()`, for data at rest. /// .for_transport_encryption() - /// .map(|ka| ka.key()) - /// .collect::<Vec<_>>(); + /// .map(|ka| ka.key()); /// /// # let mut sink = vec![]; /// let message = Message::new(&mut sink); @@ -3082,7 +3069,7 @@ mod test { let recipients = tsk .keys().with_policy(p, None) .for_storage_encryption().for_transport_encryption() - .map(|ka| ka.key()).collect::<Vec<_>>(); + .map(|ka| ka.key()); let encryptor = Encryptor::for_recipients(m, recipients) .aead_algo(AEADAlgorithm::EAX) .build().unwrap(); |