diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-05-13 09:19:27 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-05-13 14:07:28 +0200 |
commit | 2005a7c498abf88303ac29745f96998ff9d2064f (patch) | |
tree | ce1b99a98a0824ee635055fedbde32a5099e4187 /openpgp/src/packet_pile.rs | |
parent | 23dc8600f5c392a0df1e2a1867186c4230d986e6 (diff) |
openpgp: Implement From<PacketPile> for Vec<Packet>
- Provide a conversion from `PacketPile` to `Vec<Packet>` using
idiomatic interfaces.
- It would be nicer to implement `IntoIterator`, but
`PacketPile::into_children` doesn't have a concrete type (it
returns an `impl Iterator`).
Diffstat (limited to 'openpgp/src/packet_pile.rs')
-rw-r--r-- | openpgp/src/packet_pile.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs index ff9f981f..e30ab009 100644 --- a/openpgp/src/packet_pile.rs +++ b/openpgp/src/packet_pile.rs @@ -178,6 +178,12 @@ impl FromIterator<Packet> for PacketPile { } } +impl From<PacketPile> for Vec<Packet> { + fn from(pp: PacketPile) -> Self { + pp.into_children().collect() + } +} + impl PacketPile { /// Accessor for PacketPileParser. pub(crate) fn top_level_mut(&mut self) -> &mut Container { |