summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-04-13 23:44:02 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-04-14 00:16:47 +0200
commit31e3116b48ab9e8885713840fc1b7cdb10788d9b (patch)
tree2839c27c7657f044c06fe5dab86d142b5bf1268c
parentb8cd9c6efa0c901d1c8d2714bc32999671b1469d (diff)
downloadimag-31e3116b48ab9e8885713840fc1b7cdb10788d9b.zip
imag-31e3116b48ab9e8885713840fc1b7cdb10788d9b.tar.gz
Revert "Remove GetIter"
This reverts commit a49522dc86770a741d61d548351ad69dfc56d1fa.
-rw-r--r--lib/entry/libimagentrylink/src/internal.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/entry/libimagentrylink/src/internal.rs b/lib/entry/libimagentrylink/src/internal.rs
index 3f2df91..be979e0 100644
--- a/lib/entry/libimagentrylink/src/internal.rs
+++ b/lib/entry/libimagentrylink/src/internal.rs
@@ -200,6 +200,10 @@ pub mod iter {
LinkIter(v.into_iter())
}
+ pub fn into_getter(self, store: &Store) -> GetIter {
+ GetIter(self.0, store)
+ }
+
}
impl Iterator for LinkIter {
@@ -225,6 +229,32 @@ pub mod iter {
}
}
+ /// An Iterator that `Store::get()`s the Entries from the store while consumed
+ pub struct GetIter<'a>(IntoIter<Link>, &'a Store);
+
+ impl<'a> GetIter<'a> {
+ pub fn new(i: IntoIter<Link>, store: &'a Store) -> GetIter<'a> {
+ GetIter(i, store)
+ }
+
+ pub fn store(&self) -> &Store {
+ self.1
+ }
+ }
+
+ impl<'a> Iterator for GetIter<'a> {
+ type Item = Result<FileLockEntry<'a>>;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ self.0.next().and_then(|id| match self.1.get(id) {
+ Ok(None) => None,
+ Ok(Some(x)) => Some(Ok(x)),
+ Err(e) => Some(Err(e).map_err(From::from)),
+ })
+ }
+
+ }
+
}
impl InternalLinker for Entry {