diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-04-03 20:44:19 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-04-03 20:45:02 +0200 |
commit | e7f13bab21d0af8fee3e532e25c3dd59fce3b6d3 (patch) | |
tree | 576a9345667233d9ae7631802981e51da41c3037 | |
parent | e2cb547a2d4792c7a0a19fcbb9adf5342ddc7d5e (diff) |
openpgp: Return impl Iterator instead of a concrete type
-rw-r--r-- | openpgp/src/packet/mod.rs | 2 | ||||
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 3 | ||||
-rw-r--r-- | openpgp/src/packet_pile.rs | 9 |
3 files changed, 9 insertions, 5 deletions
diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs index b5c3dd2c..d2422544 100644 --- a/openpgp/src/packet/mod.rs +++ b/openpgp/src/packet/mod.rs @@ -442,7 +442,7 @@ fn packet_path_iter() { use crate::parse::Parse; use crate::PacketPile; - fn paths(iter: slice::Iter<Packet>) -> Vec<Vec<usize>> { + fn paths<'a>(iter: impl Iterator<Item=&'a Packet>) -> Vec<Vec<usize>> { let mut lpaths : Vec<Vec<usize>> = Vec::new(); for (i, packet) in iter.enumerate() { let mut v = Vec::new(); diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index 1b523227..4bcfc0f3 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -3253,7 +3253,8 @@ fn subpacket_test_2() { // } // } // } -// } + // } + () } #[test] diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs index 3539623d..bd640aa5 100644 --- a/openpgp/src/packet_pile.rs +++ b/openpgp/src/packet_pile.rs @@ -1,6 +1,5 @@ use std::convert::TryFrom; use std::fmt; -use std::slice; use std::vec; use std::io; use std::path::Path; @@ -306,12 +305,16 @@ impl PacketPile { } /// Returns an iterator over the top-level packets. - pub fn children<'a>(&'a self) -> slice::Iter<'a, Packet> { + pub fn children(&self) + -> impl Iterator<Item=&Packet> + ExactSizeIterator + { self.top_level.children().expect("toplevel is a container") } /// Returns an `IntoIter` over the top-level packets. - pub fn into_children(self) -> vec::IntoIter<Packet> { + pub fn into_children(self) + -> impl Iterator<Item=Packet> + ExactSizeIterator + { self.top_level.into_children().expect("toplevel is a container") } |