diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-05-13 16:48:49 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-05-13 16:49:49 +0200 |
commit | fb8c180a057a5c912a88a8d44f53cd53efb1d2d8 (patch) | |
tree | a918f25e3790ad50cedd1146c9ee8aa34a3606c8 /guide | |
parent | 41f8260e0c8cd04a0d2e5ddce27a48522048385c (diff) |
openpgp: Avoid constructing vectors of recipients.
- Every iterator implements IntoIterator. Simplify accordingly.
Diffstat (limited to 'guide')
-rw-r--r-- | guide/src/chapter_02.md | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/guide/src/chapter_02.md b/guide/src/chapter_02.md index 95e466f9..e3da3d80 100644 --- a/guide/src/chapter_02.md +++ b/guide/src/chapter_02.md @@ -55,12 +55,10 @@ fn main() { # fn encrypt(policy: &dyn Policy, # sink: &mut Write, plaintext: &str, recipient: &openpgp::Cert) # -> openpgp::Result<()> { -# // Build a vector of recipients to hand to Encryptor. # let recipients = # recipient.keys().with_policy(policy, 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); @@ -203,12 +201,10 @@ fn generate() -> openpgp::Result<openpgp::Cert> { # fn encrypt(policy: &dyn Policy, # sink: &mut Write, plaintext: &str, recipient: &openpgp::Cert) # -> openpgp::Result<()> { -# // Build a vector of recipients to hand to Encryptor. # let recipients = # recipient.keys().with_policy(policy, 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); @@ -351,12 +347,10 @@ implements [`io::Write`], and we simply write the plaintext to it. fn encrypt(policy: &dyn Policy, sink: &mut Write, plaintext: &str, recipient: &openpgp::Cert) -> openpgp::Result<()> { - // Build a vector of recipients to hand to Encryptor. let recipients = recipient.keys().with_policy(policy, 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); @@ -513,12 +507,10 @@ Decrypted data can be read from this using [`io::Read`]. # fn encrypt(policy: &dyn Policy, # sink: &mut Write, plaintext: &str, recipient: &openpgp::Cert) # -> openpgp::Result<()> { -# // Build a vector of recipients to hand to Encryptor. # let recipients = # recipient.keys().with_policy(policy, 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); |