From db93f01ea38999d1afa5d053837266d3b5e75500 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 29 May 2016 17:08:27 +0200 Subject: [PATCH] Add WithHtmlIterator to iterate over (Entry, Result) tuples --- libimagentrymarkdown/src/html.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libimagentrymarkdown/src/html.rs b/libimagentrymarkdown/src/html.rs index 09038751..f9d251a8 100644 --- a/libimagentrymarkdown/src/html.rs +++ b/libimagentrymarkdown/src/html.rs @@ -53,4 +53,30 @@ pub mod iter { } + + /// Iterate over `(Entry, Result)` tuples + pub struct WithHtmlIterator> { + i: I + } + + impl> WithHtmlIterator { + + fn new(i: I) -> WithHtmlIterator { + WithHtmlIterator { i: i } + } + + } + + impl> Iterator for WithHtmlIterator { + type Item = (Entry, Result); + + fn next(&mut self) -> Option { + self.i.next().map(|entry| { + let html = to_html(&entry.get_content()[..]); + (entry, html) + }) + } + + } + }