diff options
author | Neal H. Walfield <neal@pep.foundation> | 2022-03-03 13:52:09 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2022-03-03 13:52:09 +0100 |
commit | 2065d601b1ebbf2175028c0cc16b87f30db33dcf (patch) | |
tree | da82cea95f4b0c7b77e819b51473b58821f1277d | |
parent | 36cf94eb79259a481f09b43329798227b1002619 (diff) |
openpgp: Avoid unnecessarily allocating a Vec.
-rw-r--r-- | openpgp/src/cert.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs index 0924d334..33c10376 100644 --- a/openpgp/src/cert.rs +++ b/openpgp/src/cert.rs @@ -134,7 +134,6 @@ use std::collections::hash_map::DefaultHasher; use std::cmp; use std::cmp::Ordering; use std::convert::TryFrom; -use std::convert::TryInto; use std::hash::Hasher; use std::path::Path; use std::mem; @@ -2902,7 +2901,7 @@ impl TryFrom<Packet> for Cert { type Error = anyhow::Error; fn try_from(p: Packet) -> Result<Self> { - vec![ p ].try_into() + Cert::from_packets(std::iter::once(p)) } } @@ -3700,6 +3699,8 @@ impl<'a> Preferences<'a> for ValidCert<'a> #[cfg(test)] mod test { + use std::convert::TryInto; + use crate::serialize::Serialize; use crate::policy::StandardPolicy as P; use crate::types::Curve; |