summaryrefslogtreecommitdiffstats
path: root/openpgp/src/serialize
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-05-13 16:48:49 +0200
committerJustus Winter <justus@sequoia-pgp.org>2020-05-13 16:49:49 +0200
commitfb8c180a057a5c912a88a8d44f53cd53efb1d2d8 (patch)
treea918f25e3790ad50cedd1146c9ee8aa34a3606c8 /openpgp/src/serialize
parent41f8260e0c8cd04a0d2e5ddce27a48522048385c (diff)
openpgp: Avoid constructing vectors of recipients.
- Every iterator implements IntoIterator. Simplify accordingly.
Diffstat (limited to 'openpgp/src/serialize')
-rw-r--r--openpgp/src/serialize/stream.rs27
1 files changed, 7 insertions, 20 deletions
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();