diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-08-07 22:24:42 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-08-07 22:51:34 +0200 |
commit | a5d6f12eb8ca200478f1be2531d2ee122cc8b5f9 (patch) | |
tree | 593449f15243582eb3d2f5e0fe16ab789f90af9c | |
parent | dbf7ec81e77e04398c63f10f661414e5a5470b77 (diff) |
openpgp: Take a reference instead of a vector.
- Change `SignatureBuilder::set_intended_recipients` to take an
`AsRef<[Fingerprint]>` instead of a vector.
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index 011e8367..6945b8a3 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -4983,20 +4983,20 @@ impl signature::SignatureBuilder { /// let msg = b"Let's do it!"; /// /// let sig = SignatureBuilder::new(SignatureType::Binary) - /// .set_intended_recipients(vec![ bob.fingerprint(), carol.fingerprint() ])? + /// .set_intended_recipients(&[ bob.fingerprint(), carol.fingerprint() ])? /// .sign_message(&mut alices_signer, msg)?; /// # assert!(sig.verify_message(alices_signer.public(), msg).is_ok()); /// # assert_eq!(sig.intended_recipients().iter().count(), 2); /// # Ok(()) } /// ``` - /// Sets the intended recipients. - pub fn set_intended_recipients(mut self, recipients: Vec<Fingerprint>) + pub fn set_intended_recipients<T>(mut self, recipients: T) -> Result<Self> + where T: AsRef<[Fingerprint]> { self.hashed_area.remove_all(SubpacketTag::IntendedRecipient); - for fp in recipients.into_iter() { + for fp in recipients.as_ref().into_iter() { self.hashed_area.add( - Subpacket::new(SubpacketValue::IntendedRecipient(fp), false)?)?; + Subpacket::new(SubpacketValue::IntendedRecipient(fp.clone()), false)?)?; } Ok(self) |